Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 293210

Re: Need a script to get hosts where observed IP-Range

$
0
0

You can add one more calculated property on the Select-Object cmdlet.

Something like this

 

foreach($esx in Get-VMHost){
    $vms = Get-VM -Location $esx
    foreach($pg in (Get-VirtualPortGroup -VMHost $esx)){         $vms | where {$_.Guest.Nics | where {$_.NetworkName -eq $pg.Name}} |         Select @{N="Host";E={$esx.Name}},             @{N="PG";E={$pg.Name}},             @{N="VLANid";E={$pg.VlanId}},             @{N="IP";E={[string]::Join(',',($_.Guest.Nics | where {$_.NetworkName -eq $pg.Name} | %{$_.IPAddress | %{$_}}))}},             @{N="VM";E={$_.Name}}     } }

Viewing all articles
Browse latest Browse all 293210

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>