- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to retrieve the Azure VM NIC name using PowerShell?
To retrieve the Azure VM NIC using PowerShell, we need to first get the VM details. For this example, we have the VM name “TestMachine2k16”. To retrieve the VM details use the Get-AzVM command but before that make sure you are connected to the Azure Account using PowerShell session.
PS C:\> $vm = Get-AzVM -VMName Testmachine2k16
VM NIC information is stored inside the NetworkProfile property.
PS C:\> $vm.NetworkProfile
This will retrieve all the NICs attached to the VM. If there are multiple NICs then we need to store the nic information into the array and have to perform some string operation to get the NIC details.
$nics = $vm.NetworkProfile.NetworkInterfaces
To retrieve the NIC details.
foreach($nic in $nics) { ($nic.Id -split '/')[-1] }
The above output will retrieve the NICs attached to the VM.
- Related Articles
- How to retrieve the Azure VM nic name using Azure CLI in PowerShell?
- How to retrieve the Azure VM Subscription Name using PowerShell?
- How to retrieve the Azure VM vNet name using PowerShell?
- How to retrieve the Azure VM resource group using PowerShell?
- How to retrieve the Azure VM deallocated date using PowerShell?
- How to retrieve the OS of the Azure VM using Azure CLI in PowerShell?
- How to retrieve the Operating system of the Azure VM using PowerShell?
- How to retrieve the Azure VM RAM and CPU size using PowerShell?
- How to retrieve the Azure VM network security group (NSG) using PowerShell?
- How to retrieve the OS caching setting of Azure VM using Azure\nCLI in PowerShell?
- How to get the Azure VM DNS name using PowerShell?
- How to deallocate the Azure VM using Azure CLI in PowerShell?
- How to start the Azure VM using Azure CLI in PowerShell?
- How to stop the Azure VM using Azure CLI in PowerShell?
- How to restart the Azure VM using Azure CLI in PowerShell?

Advertisements