Chirag Nagrekar has Published 468 Answers

How to get the location of the Azure VM using Azure CLI in PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 31-Aug-2021 09:47:35

To find the location of the particular Azure VM using Az CLI, we can use the below command but before that, you need to make sure you are connected to the Azure cloud and had set that specific subscription.PS C:\> az vm show -n VMName -g ResourceGroupName --query '[location]' -otsvAlternatively, ... Read More

How to list the Azure VMs using Azure CLI in PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 31-Aug-2021 09:46:33

To list all the Azure VMs connected to the particular subscription, we need to use the “Az vm” command. Before that, we need to make sure the Azure is connected to the desired subscription, if not use the below command to set the Azure Subscription.az account set -s 'subscription name ... Read More

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

Chirag Nagrekar

Chirag Nagrekar

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

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

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

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

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

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, AddressPrefixRead More

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

Chirag Nagrekar

Chirag Nagrekar

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

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

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

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

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