Automation

 View Only
  • 1.  Observed IP Ranges

    Broadcom Employee
    Posted Dec 08, 2008 10:46 AM

    Hi,

    Is it possible to get the 'Observed IP Ranges' for each nic in each host, couldnt find where it was recorded ?!

    Thanks



  • 2.  RE: Observed IP Ranges

    Broadcom Employee
    Posted Dec 08, 2008 11:40 AM

    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



  • 3.  RE: Observed IP Ranges

    Broadcom Employee
    Posted Dec 08, 2008 01:38 PM

    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  &lt;&lt;&lt;&lt; $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( &lt;&lt;&lt;&lt; $<br/><br/>
    _.device)} |%{$_.Subnet}
    

    </p>



  • 4.  RE: Observed IP Ranges
    Best Answer

    Posted Dec 08, 2008 02:01 PM

    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
    	  }
    	}
      }
    }
    



  • 5.  RE: Observed IP Ranges

    Broadcom Employee
    Posted Dec 08, 2008 02:09 PM

    Amazing as always LucD

    Thanks.



  • 6.  RE: Observed IP Ranges

    Posted Dec 08, 2008 02:21 PM

    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
    				}
    			}
    		}
    	}
    }
    



  • 7.  RE: Observed IP Ranges

    Broadcom Employee
    Posted Dec 08, 2008 02:23 PM

    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



  • 8.  RE: Observed IP Ranges

    Posted Dec 08, 2008 02:27 PM

    Scary, the twilight zone :smileywink:



  • 9.  RE: Observed IP Ranges

    Broadcom Employee
    Posted Dec 08, 2008 03:04 PM

    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 ?



  • 10.  RE: Observed IP Ranges

    Posted Dec 08, 2008 04:50 PM

    See .



  • 11.  RE: Observed IP Ranges

    Broadcom Employee
    Posted Dec 08, 2008 08:57 PM

    Thanks LucD Didnt search for that one :smileyhappy: