Hi @MAHESH NIKAM ,
I'm no WMI expert but these different commands below will get you the following:
- IP addresses
- Virtual Switch name
- MAC Address
- Network Adapter name
Gets the network adapter name & MAC address of the Hyper-V guest virtual machine
$VMName = "VMname"
$VMNet = Get-WmiObject -Namespace root\virtualization\v2 -Class Msvm_ComputerSystem -Filter "ElementName='$VMName'"
$VMNet.GetRelated('Msvm_SyntheticEthernetPort') | Select ElementName, PermanentAddress
Gets the Hyper-V switch name of the Hyper-V guest virtual machine
$VMName = "VMname"
$VMSwitch = Get-WmiObject -Namespace root\virtualization\v2 -Class Msvm_ComputerSystem -Filter "ElementName='$VMName'"
$VMSwitch.GetRelated('Msvm_SummaryInformation') | Select VirtualSwitchNames
Gets the IP addresses of the Hyper-V guest virtual machine
$VMName = "VMname"
$Msvm_VirtualSystemManagementService = Get-WmiObject -Namespace root\virtualization\v2 -Class Msvm_VirtualSystemManagementService
$Msvm_ComputerSystem = Get-WmiObject -Namespace root\virtualization\v2 -Class Msvm_ComputerSystem -Filter "ElementName='$VMName'"
$Msvm_VirtualSystemSettingData = ($Msvm_ComputerSystem.GetRelated("Msvm_VirtualSystemSettingData","Msvm_SettingsDefineState", $null, $null, "SettingData", "ManagedElement", $false, $null) | % {$_})
$Msvm_SyntheticEthernetPortSettingData = $Msvm_VirtualSystemSettingData.GetRelated("Msvm_SyntheticEthernetPortSettingData")
$Msvm_GuestNetworkAdapterConfiguration = ($Msvm_SyntheticEthernetPortSettingData.GetRelated("Msvm_GuestNetworkAdapterConfiguration"))
$Msvm_GuestNetworkAdapterConfiguration | Select IPAddresses
----------
(If the reply was helpful please don't forget to upvote or accept as answer, thank you)
Best regards,
Leon