ESXi/ESX host build numbers – update levels

vmware knowledge base article: KB: 1014508

vmware -v

Advertisements

ESX host or guest IP address inventory via PowerCLI

IPaddresses = @()

foreach($vm in Get-VM){     $vm.Guest.Nics | %{         $row = “” | Select Name, IP, MAC         $row.Name = $vm.Name         $row.IP = &{if($_.IPAddress){[String]::Join(‘,’,$_.IPAddress)}}         $row.MAC = $_.MacAddress         $IPaddresses += $row     } }

$IPaddresses = @()

Get-VMHost | Get-VMHostNetworkAdapter -VMKernel | %{     $row = “” | Select Name, IP, MAC     $row.Name = $_.VMHost.Name     $row.IP = $_.IP     $row.MAC = $_.MAC     $IPaddresses += $row }

$IPaddresses

 

or

 

Get-VMHostNetworkAdapter | select VMhost, Name, IP, SubnetMask | Export-Csv -NoTypeInformation C:\temp\host.csv

 

vbscript based computer inventory scripts

strComputer = “.” Set objWMIService = GetObject(“winmgmts:” _     & “{impersonationLevel=impersonate}!\\” _     & strComputer & “\root\cimv2”) Set colOperatingSystems = objWMIService.ExecQuery _     (“Select * from Win32_OperatingSystem”) For Each objOperatingSystem in colOperatingSystems     Wscript.Echo objOperatingSystem.Caption & _     ”  ” & objOperatingSystem.Version Next

strComputer = “.” Set objWMIService = GetObject( _     “winmgmts:\\” & strComputer & “\root\cimv2”) Set IPConfigSet = objWMIService.ExecQuery _     (“Select IPAddress from Win32_NetworkAdapterConfiguration” _         & ” where IPEnabled=TRUE”)   For Each IPConfig in IPConfigSet     If Not IsNull(IPConfig.IPAddress) Then         For i=LBound(IPConfig.IPAddress) _         to UBound(IPConfig.IPAddress)             WScript.Echo IPConfig.IPAddress(i)         Next     End If Next

various WMI computer inventory commands via Powershell

wmi Win32_OperatingSystem.CSName
gwmi Win32_OperatingSystem.Name

Get-WmiObject Win32_OperatingSystem).Name | format-list

(Get-WmiObject Win32_OperatingSystem).CSName

Get-WmiObject Win32_OperatingSystem | Format-List csname, name

Get-WmiObject Win32_NetworkAdapterConfiguration | Format-List IPAddress

Get-WmiObject Win32_OperatingSystem | Format-List csname, name

gwmi Win32_NetworkAdapterConfiguration |     Where { $_.IPAddress } | # filter the objects where an address actually exists     Select -Expand IPAddress | # retrieve only the property *value*     Where { $_ -like ‘192.168.*’ }

Get active directory role with vbscript

sComputer = “.” WScript.Echo DomainRole(sComputer)

Function DomainRole(sNode) Set oWMI = GetObject(“winmgmts:” _ & “{impersonationLevel=impersonate}!\\” & sNode & “\root\cimv2”) Set colComputer = oWMI.ExecQuery _ (“Select DomainRole from Win32_ComputerSystem”) For Each oComputer in colComputer iDR = oComputer.DomainRole Next

Select Case iDR Case 0 DomainRole = “Standalone Workstation” Case 1 DomainRole = “Member Workstation” Case 2 DomainRole = “Standalone Server” Case 3 DomainRole = “Member Server” Case 4 DomainRole = “Backup Domain Controller” Case 5 DomainRole = “Primary Domain Controller” Case Else DomainRole = “Unknown” End Select

End Function