Quantcast
Channel: VMware Communities : All Content - All Communities
Viewing all articles
Browse latest Browse all 180923

Observed IP Ranges

$
0
0

Hey Guys,

I need some help to modify a script I found here. Basically i need to obtain esxi server name, not the vmhostid and if its posible add a column with the cluster name,

 

Thanks in advance!

Fer

 

 

This is the output i obtain with the below script

VMHostId                                  Device                         IPSubnet                                               Vlan

HostSystem-host-52823           vmnic0                         xxx.xxx.34.128-xxx.xxx.34.254                             934

 

I hope someone can help me.

 

function Get-ObservedIPRange {

[CmdletBinding()]
param(
[Parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$True,HelpMessage=”Physical NIC from Get-VMHostNetworkAdapter”)]
[Object[]]$Nics

)

process {

forEach ($Nic in $Nics)
{

if($Nic -notlike “vmk*”)
{
[VMware.VimAutomation.Client20.Host.NIC.PhysicalNicImpl]$NicImpl = $Nic
$hostView = Get-VMHost -Id $NicImpl.VMHostId | Get-View -Property ConfigManager
$ns = Get-View $hostView.ConfigManager.NetworkSystem
$hints = $ns.QueryNetworkHint($NicImpl.Name)

foreach ($hint in $hints)
{
if( ($hint.ConnectedSwitchPort) )
{
foreach ($subnet in $hint.subnet)
{
$observed = New-Object -TypeName PSObject
$observed | Add-Member -MemberType NoteProperty -Name Device -Value $NicImpl.Name
$observed | Add-Member -MemberType NoteProperty -Name VMHostId -Value $NicImpl.VMHostId
$observed | Add-Member -MemberType NoteProperty -Name IPSubnet -Value $subnet.IPSubnet
$observed | Add-Member -MemberType NoteProperty -Name VlanId -Value $subnet.VlanId
Write-Output $observed
}
}
}

}

}
}

}


Viewing all articles
Browse latest Browse all 180923

Trending Articles



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