Retrieve Azure VM NIC Name Using Azure CLI in PowerShell



To get the Azure VM NIC name using Azure CLI, use the below command but before running the command make sure that you are connected to the Azure Account and the proper Azure subscription using Azure CLI.

az vm show -n AzureVM -g ResourceGroup --query
'[networkProfile.networkInterfaces][].id' -otsv

We need the NIC name from this. If you are running the Azure CLI in the PowerShell terminal then use the command below.

PS C:\> $nicinfo = az vm show -n VMname -g RGName --query
'[networkProfile.networkInterfaces][].id' -otsv
PS C:\> ($nicinfo.Split('/'))[-1]
Chirag Nagrekar
Chirag Nagrekar

Updated on: 2021-09-01T09:49:50+05:30

467 Views

Kickstart Your Career

Get certified by completing the course

Get Started