{"id":520,"date":"2014-05-01T11:14:33","date_gmt":"2014-05-01T11:14:33","guid":{"rendered":"http:\/\/giraffeit.com\/?p=520"},"modified":"2025-06-04T18:14:25","modified_gmt":"2025-06-04T18:14:25","slug":"exportvirtualips","status":"publish","type":"post","link":"https:\/\/giraffeit.com\/index.php\/2014\/05\/01\/exportvirtualips\/","title":{"rendered":"Powershell export virtual machines IP"},"content":{"rendered":"<p>This script is pretty handy, it will connect to the Virtual Center you specify in Powershell.<\/p>\n<p># you will need to adjust the viserver name<br \/>\nconnect-viserver someserver.eu.kellogg.com<\/p>\n<p>$reportedvms=New-Object System.Collections.ArrayList<br \/>\n$vms=get-view -viewtype virtualmachine |Sort-Object -Property { $_.Config.Hardware.Device | where {$_ -is [VMware.Vim.VirtualEthernetCard]} | Measure-Object | select -ExpandProperty Count} -Descending<\/p>\n<p>foreach($vm in $vms){<br \/>\n$reportedvm = New-Object PSObject<br \/>\nAdd-Member -Inputobject $reportedvm -MemberType noteProperty -name Guest -value $vm.Name<br \/>\nAdd-Member -InputObject $reportedvm -MemberType noteProperty -name UUID -value $($vm.Config.Uuid)<br \/>\n$networkcards=$vm.guest.net | ?{$_.DeviceConfigId -ne -1}<br \/>\n$i=0<br \/>\nforeach($ntwkcard in $networkcards){<br \/>\nAdd-Member -InputObject $reportedvm -MemberType NoteProperty -Name &#8220;networkcard${i}.Network&#8221; -Value $ntwkcard.Network<br \/>\nAdd-Member -InputObject $reportedvm -MemberType NoteProperty -Name &#8220;networkcard${i}.MacAddress&#8221; -Value $ntwkcard.Macaddress<br \/>\nAdd-Member -InputObject $reportedvm -MemberType NoteProperty -Name &#8220;networkcard${i}.IpAddress&#8221; -Value $($ntwkcard.IpAddress|?{$_ -like &#8220;*.*&#8221;})<br \/>\nAdd-Member -InputObject $reportedvm -MemberType NoteProperty -Name &#8220;networkcard${i}.Device&#8221; -Value $(($vm.config.hardware.device|?{$_.key -eq $($ntwkcard.DeviceConfigId)}).gettype().name)<br \/>\n$i++<br \/>\n}<br \/>\n$reportedvms.add($reportedvm)|Out-Null<br \/>\n}<\/p>\n<p>$reportedvms|Export-Csv c:myreport.csv<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This script is pretty handy, it will connect to the Virtual Center you specify in Powershell. # you will need to adjust the viserver name connect-viserver someserver.eu.kellogg.com $reportedvms=New-Object System.Collections.ArrayList $vms=get-view -viewtype virtualmachine |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 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/giraffeit.com\/index.php\/2014\/05\/01\/exportvirtualips\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Powershell export virtual machines IP&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"class_list":["post-520","post","type-post","status-publish","format-standard","hentry","category-bog"],"_links":{"self":[{"href":"https:\/\/giraffeit.com\/index.php\/wp-json\/wp\/v2\/posts\/520","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/giraffeit.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/giraffeit.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/giraffeit.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/giraffeit.com\/index.php\/wp-json\/wp\/v2\/comments?post=520"}],"version-history":[{"count":1,"href":"https:\/\/giraffeit.com\/index.php\/wp-json\/wp\/v2\/posts\/520\/revisions"}],"predecessor-version":[{"id":856,"href":"https:\/\/giraffeit.com\/index.php\/wp-json\/wp\/v2\/posts\/520\/revisions\/856"}],"wp:attachment":[{"href":"https:\/\/giraffeit.com\/index.php\/wp-json\/wp\/v2\/media?parent=520"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/giraffeit.com\/index.php\/wp-json\/wp\/v2\/categories?post=520"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/giraffeit.com\/index.php\/wp-json\/wp\/v2\/tags?post=520"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}