
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Retrieve 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.
Advertisements