Hi,
Is it possible to get the 'Observed IP Ranges' for each nic in each host, couldnt find where it was recorded ?!
Thanks
When you have more than 1 ESX server the script becomes a bit more complex.
Try this:
$networkSystem = Get-VMHost | Get-View | %{Get-View $_.ConfigManager.NetworkSystem} foreach($netSys in $networkSystem){ foreach($pnic in $netSys.NetworkConfig.Pnic){ $subnets = $netSys.QueryNetworkHint($pnic.Device) foreach($pnicHint in $subnets){ Write-Host $pnicHint.Device foreach($pnicIpHint in $pnicHint.Subnet){ Write-Host "`t" $pnicIpHint.IpSubnet } } } }
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
It's located in ipSubnet property of the PhysicalNicIpHint. You can get PhysicalNicIpHint object from HostNetworkSystem.QueryNetworkHint()
$h = Get-VMHost | Get-View $networkSystem = Get-View $h.ConfigManager.NetworkSystem $networkSystem.NetworkConfig.Pnic | %{$networkSystem.QueryNetworkHint($_.device)} |%{$_.Subnet}
Regards,
Yasen
Thanks, Unfortunatly Im getting the following error:
Get-View : The argument cannot be null or empty.<br /><br/> At C:\DOCUME~1\me\LOCALS~1\Temp\1\28cc7d0d-6c96-4307-b748-2552ba12c58f.ps1:<br/><br/> 3 char:26<br/><br/> + $networkSystem = Get-View <<<< $h.ConfigManager.NetworkSystem<br/><br/> You cannot call a method on a null-valued expression.<br/><br/> At C:\DOCUME~1\me\LOCALS~1\Temp\1\28cc7d0d-6c96-4307-b748-2552ba12c58f.ps1:<br/><br/> 4 char:70<br/><br/> + $networkSystem.NetworkConfig.Pnic | %{$networkSystem.QueryNetworkHint( <<<< $<br/><br/> _.device)} |%{$_.Subnet}
</p>
When you have more than 1 ESX server the script becomes a bit more complex.
Try this:
$networkSystem = Get-VMHost | Get-View | %{Get-View $_.ConfigManager.NetworkSystem} foreach($netSys in $networkSystem){ foreach($pnic in $netSys.NetworkConfig.Pnic){ $subnets = $netSys.QueryNetworkHint($pnic.Device) foreach($pnicHint in $subnets){ Write-Host $pnicHint.Device foreach($pnicIpHint in $pnicHint.Subnet){ Write-Host "`t" $pnicIpHint.IpSubnet } } } }
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Amazing as always LucD
Thanks.
It's probably useful to list the ESX hostname as well.
$esxList = Get-VMHost | Get-View foreach($esx in $esxList){ Write-Host $esx.Name $networkSystem = Get-View $esx.ConfigManager.NetworkSystem foreach($netSys in $networkSystem){ foreach($pnic in $netSys.NetworkConfig.Pnic){ Write-Host $subnets = $netSys.QueryNetworkHint($pnic.Device) foreach($pnichint in $subnets){ Write-Host "`t" $pnichint.Device foreach($pniciphint in $pnichint.Subnet){ Write-Host "`t`t" $pniciphint.IpSubnet } } } } }
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
ha ha snap !
$vmhosts = Get-VMHost | Get-View foreach ($vmhost in $vmhosts) { $networkSystem = Get-view $vmhost.ConfigManager.NetworkSystem Write-Host $vmhost.Name -foregroundcolor yellow foreach($netSys in $networkSystem) { foreach($pnic in $netSys.NetworkConfig.Pnic) { $subnets = $netSys.QueryNetworkHint($pnic.Device) foreach($pnicHint in $subnets) { Write-Host $pnicHint.Device foreach($pnicIpHint in $pnicHint.Subnet) { Write-Host "`t" $pnicIpHint.IpSubnet } } } } }
Alan
Scary, the twilight zone
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Du du du du, Du du du du (sounded better in my head !)
Ok, just had a request to add the Cisco Discovery Protocol Info, any ideas where the info is stored ?
See .
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks LucD Didnt search for that one