Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $reportedvms=New-Object System.Collections.ArrayList
- $vms=get-view -viewtype virtualmachine -Filter @{'Runtime.PowerState'='poweredOn'} |Sort-Object -Property { $_.Config.Hardware.Device | where {$_ -is [VMware.Vim.VirtualEthernetCard]} | Measure-Object | select -ExpandProperty Count} -Descending
- foreach($vm in $vms){ $reportedvm = New-Object PSObject
- Add-Member -Inputobject $reportedvm -MemberType NoteProperty -name Guest -value $vm.Name
- $networkcards=$vm.guest.net | ?{$_.DeviceConfigId -ne -1}
- $i=0
- foreach($ntwkcard in $networkcards){
- Add-Member -InputObject $reportedvm -MemberType NoteProperty -Name "networkcard${i}.MacAddress" -Value $ntwkcard.Macaddress
- Add-Member -InputObject $reportedvm -MemberType NoteProperty -Name "networkcard${i}.IpAddress" -Value $($ntwkcard.IpAddress|?{$_ -like "*.*"})
- $i++
- }
- $reportedvms.add($reportedvm)|Out-Null
- }
- $reportedvms|Export-Csv c:\tools\myreport.csv
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement