Hi all,
I would like some help to provide a html document (with convert-html) that have three columns (VM Name, Type of @MAC (manual or assigned), @MAC).
I have search in the forum and I have found the command line to obtain all mac address for all VM : Get-VM | select name, @{Name="MAC"; expression={foreach($nic in (Get-View $_.ID).guest.net) {$nic.macAddress}}} but the parameters manual or assigned or not display.
Could you help me ?
Thank you for your help.
Regards.
The addressType property is not in that object.
With this script you should get the MAC address type
$report =@() Get-VM | Get-View | %{ $VMname = $_.Name $_.Config.Hardware.Device | where {$_.DeviceInfo.Label -match "Network Adapter"} | %{` $row = "" | Select VM, MAC, Type $row.VM = $VMname $row.MAC = $_.MacAddress $row.Type = $_.AddressType $report += $row } } $report
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
The addressType property is not in that object.
With this script you should get the MAC address type
$report =@() Get-VM | Get-View | %{ $VMname = $_.Name $_.Config.Hardware.Device | where {$_.DeviceInfo.Label -match "Network Adapter"} | %{` $row = "" | Select VM, MAC, Type $row.VM = $VMname $row.MAC = $_.MacAddress $row.Type = $_.AddressType $report += $row } } $report
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks a lot. It's work Fine, just a 'after { must be delete.
Have a nice day.
Hi
great script thanks, !!!
is there a possibility to add a search mask for only specified vm's. Like run the script only in vm where the name contains production or so?
best regards, Sven
Sure, the Get-Vm cmdlet accepts masks
$report =@() Get-VM "*production*" | Get-View | %{ $VMname = $_.Name $_.Config.Hardware.Device | where {$_.DeviceInfo.Label -match "Network Adapter"} | %{ $row = "" | Select VM, MAC, Type $row.VM = $VMname $row.MAC = $_.MacAddress $row.Type = $_.AddressType $report += $row } } $report
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I try to run the script in PowerGUI. But no entry's are displayed. I think it's a problem with the rows.
best regars, sven
hey LucD
many many thanks,