Chirag Nagrekar has Published 465 Articles

How to get the Azure resource group using Azure CLI in PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 31-Aug-2021 09:45:49

7K+ Views

To get all the Azure resource groups connected to the particular subscription use the az group command.Before using this command make sure you are connected with the Azure account and if not connect the azure account with the “Az login”Once you are connected to the Azure account, set the subscription ... Read More

How to connect to the Azure subscription using Azure CLI in PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 31-Aug-2021 09:45:03

8K+ Views

To connect to the specific azure subscription using Az CLI we need to use “Az account set” command but before using this command make sure you are connected with the Azure cloud using “az login” account.az account set --subscription 'subscription name or id'You can also use -s instead of --subscription.az ... Read More

How to log in to the Azure account using Az CLI command in PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 31-Aug-2021 09:42:58

12K+ Views

To login to the Azure account using Azure CLI, we need to use the az login command. Once you type the az login command, it will prompt for the Azure portal login console.If you need to log in with the device authentication code in the browser, you need to use ... Read More

How to get the Application security groups of the Azure VM using PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 31-Aug-2021 09:40:48

431 Views

To get the Application security groups of the Azure VM using PowerShell, we need to first get the Network Interface of the Azure VM.The below command will retrieve the NIC name of the Azure VM.PS C:\> $vm = Get-AzVM -Name TestVM $nic = (($vm.NetworkProfile.NetworkInterfaces.id).Split('/'))[-1]Once we have the NIC name, we ... Read More

How to retrieve the Azure subnets connected to the virtual network using PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 31-Aug-2021 09:38:11

2K+ Views

To get all the subnets attached to the virtual network using PowerShell, we need to use the GetAzVirtualNetwork command.PS C:\> $vn = Get-AzVirtualNetwork -Name VirtualNetworkNameTo get the Subnets and its address prefix details, you need to filter out the Subnets and AddressPrefixPS C:\> $vn.Subnets | Select Name, AddressPrefix

How to find the file modified after a certain date using PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 31-Aug-2021 08:48:36

14K+ Views

To get all the files that are modified after certain days, we need to use the LastWriteTime property.The below command shows us the files which are modified within the last 30 days in the C:\temp folder.Get-ChildItem C:\Temp | where{$_.LastWriteTime -ge (GetDate).AddDays(-30)}You can also use the AddMonths() or AddYears() instead of ... Read More

How to change the local user account password using PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 17-May-2021 13:39:09

9K+ Views

To change the local user account password using PowerShell, we can use the Set-LocalUser command with the Password parameter. This password parameter should be in the secure string. So we need to ask the user to input the password as a secure string or need to explicitly convert the plain ... Read More

How to get the file extension using PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 17-May-2021 13:12:57

8K+ Views

We can retrieve the file extension using multiple ways. First, using the [System.IO.Path] class.PS C:\> [System.IO.Path]::GetExtension("C:\temp\25Aug2020.txt") .txt PS C:\> [System.IO.Path]::GetExtension("C:\temp\azcopy.zip") .zipThis is the easiest way to get the file extension. Otherways, Using programmatically, PS C:\> ((Split-Path "C:\Temp\azcopy.zip" -Leaf).Split('.'))[1] zip PS C:\> ((Split-Path "C:\Temp\25Aug2020.txt" -Leaf).Split('.'))[1] txtUsing Get-ChildItem, PS C:\> (Get-ChildItem C:\Temp\azcopy.zip).Extension ... Read More

How to set the local user account settings using PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 17-May-2021 12:51:03

2K+ Views

To set the local user account settings related to the account or the password expiration, we can use the Set-LocalUser command.The below command will change the local user Testuser account and password set to never expire.Set-LocalUser -Name Testuser -AccountNeverExpires -PasswordNeverExpires $true -VerboseThe below command will set the account expiry, Set-LocalUser ... Read More

How to find the locked local user accounts using PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 17-May-2021 12:48:43

1K+ Views

To get the locked user accounts on the local or the remote machines using PowerShell, we can use the wmi method.PS C:\> gwmi win32_useraccount | where{$_.Lockout -eq $true}You can also use the CIM instance method alternatively.PS C:\> Get-CimInstance Win32_Useraccount | where{$_.Lockout -eq $true}To get the locked local user accounts on ... Read More

Previous 1 ... 7 8 9 10 11 ... 47 Next
Advertisements