VMware Cloud Community
chakoe
Enthusiast
Enthusiast

Read VMHosts-Serialnumber via PowerCLI....possible?

Hi,

is ist possible to read the ESX-Host-Serialnumber?

Thx in advance...

Chakoe

Reply
0 Kudos
5 Replies
RvdNieuwendijk
Leadership
Leadership

Try my script in http://communities.vmware.com/message/1705969#1705969.

Regards, Robert

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
Reply
0 Kudos
chakoe
Enthusiast
Enthusiast

Hi Robert,

I´ve added a host to read (Line 48, Get-VMhost...) tried to start the script, but received the following error:

Get-WSManInstance : Access denied
At C:\Dokumente und Einstellungen\Username\Lokale Einstellungen\Temp\bb485930-9212-40bc-9133-5223289548a4.ps1:44 char:26
+         Get-WSManInstance <<<<  -Authentication basic -ConnectionURI $uri -Credential $credential -Enumerate -Port 443 -UseSSL -SessionOption $option -ResourceURI "$baseUrl/$class"
    + CategoryInfo          : InvalidOperation: (:) [Get-WSManInstance], UnauthorizedAccessException
    + FullyQualifiedErrorId : Exception,Microsoft.WSMan.Management.GetWSManInstanceCommand

Get-WSManInstance : <f:WSManFault xmlns:f="http://schemas.microsoft.com/wbem/wsman/1/wsmanfault" Code="5" Machine="workstation1"><f:Message>Zugriff verweigert </f:Messag
e></f:WSManFault>
At C:\Dokumente und Einstellungen\Username\Lokale Einstellungen\Temp\bb485930-9212-40bc-9133-5223289548a4.ps1:44 char:26
+         Get-WSManInstance <<<<  -Authentication basic -ConnectionURI $uri -Credential $credential -Enumerate -Port 443 -UseSSL -SessionOption $option -ResourceURI "$baseUrl/$class"
    + CategoryInfo          : InvalidOperation: (http://schemas....PhysicalPackage:Uri) [Get-WSManInstance], InvalidOperationException
    + FullyQualifiedErrorId : WsManError,Microsoft.WSMan.Management.GetWSManInstanceCommand

Do i need special accessrights?

Thx

Chakoe

Reply
0 Kudos
RvdNieuwendijk
Leadership
Leadership

When connected to a vCenter server I don't need special access rights. But you can try to specify host credentials as in:

$HostCredential = Get-Credential
Get-VMHost | ForEach-Object {
  $VMHost = $_
  $PhysicalPackage = Get-VMHostWSManInstance -VMHost $_ -class CIM_PhysicalPackage -ignoreCertFailures -Credential $HostCredential | `
    Where-Object {$_.ElementName -eq "Chassis"}
  $Report = "" | Select-Object -Property VMHost,SerialNumber
  $Report.VMHost = $VMHost.Name
  $Report.SerialNumber = $PhysicalPackage.SerialNumber
  $Report
} | Export-Csv -NoTypeInformation -UseCulture -Path c:\Temp\EsxSerialNumbers.csv 

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
Reply
0 Kudos
zxr45
Contributor
Contributor

How would I implement into this script to get BMC/IDRAC address of all of my hosts in vcenter.

Thanks

Reply
0 Kudos
bulletprooffool
Champion
Champion

You could use plink to initiate an ssh connection to the host and then use RACADM to scrape the information that you are after.

One day I will virtualise myself . . .
Reply
0 Kudos