The Deployment Bunny

OS Deployment, Virtualization, Microsoft based Infrastructure…

  • about.me

    about.me/mikaelnystrom

  • Archives

  • Meta

Nice to Know – Getting Hardware info(iLO) data using native PowerShell (and no need for credentials)

Posted by Mikael Nystrom on December 18, 2013

During my daily work (building datacenters) I normally need to inventory server information and in many cases there is no infrastructure in place, things like OpsMgr, SCCM, SCVMM and HP’s native tools does not really exists (yet). But for me to be able to redeploy machines, patch machines and get some kind order out of the chaos I need to know.

First step – Getting the idea of it

In HP Servers there is something called iLO, for many people it is the life-line to logon to and do remote console and access, what many people does not know is that you can reach that information using a normal web browser, like this:

Just browse to http://IPaddress/xmldata?item?All and you will se this

image

Next Step – Reading the information using PowerShell and treat it as a PSObject

The basic ide here is to read from each and every IP, the first thing is to try to get the name from DNS, then we load the XML data, we then convert, modify, bend and twist so it looks the way I need it and last we dump it in a way we like to view it. In this case dumping means Out-Gridview, but it could easily be anything else. You could also add something that “sweeps” the network and try to read it as XML to get a “iLO Scanner”. There is a PowerShell toolkit that gives us a massive amount of CMDlets and they are nice, but, the all require some kind of authentication, this does not require anything at all :-)

image

(in textform)

$iLOIP = "192.168.133.15","192.168.133.16","192.168.133.133","192.168.133.142"

Function GetiLOData {
    foreach ($IP in $ILOIP){
    $XML = New-Object XML
    $HostName = Resolve-DnsName -Name $IP
    $XML.Load("http://$IP/xmldata?item=All")
    New-Object PSObject -Property @{
      iLOName = $($HostName.NameHost);
      iLOIP = $($IP);
      ServerType = $($XML.RIMP.HSI.SPN);
      ProductID = $($XML.RIMP.HSI.PRODUCTID);
      UUID = $($XML.RIMP.HSI.cUUID);
      Nic01 = $($XML.RIMP.HSI.NICS.NIC[0].MACADDR);
      Nic02 = $($XML.RIMP.HSI.NICS.NIC[1].MACADDR);
      ILOType = $($XML.RIMP.MP.PN);
      iLOFirmware = $($XML.RIMP.MP.FWRI)
    }
}
}

GetiLOData | Select iLOName,iLOIP,ServerType,ProductID,Nic01,Nic02,UUID,iLOType,iLOFirmware | Out-GridView

Next Step – Enjoy the view

image

You can download the PowerShell script here http://sdrv.ms/ITvFyO

/mike

8 Responses to “Nice to Know – Getting Hardware info(iLO) data using native PowerShell (and no need for credentials)”

  1. […] Nice to Know – Getting Hardware info(iLO) data using native PowerShell (and no need for creden… […]

  2. […] Out of Band or Bare Metal installation requires information regarding the hardware, that is no surprise. We need to to be able to define settings that can be retried from the hardware. In many/most client deployment scenarios I see people using the MAC Address or, Serial Number but I use the GUID number. When it comes to server they don’t really have one NIC and when it comes to Hyper-V that MAC address will be more or less removed since the machine in most cases is turning the NICs into switches and then virtual NICs will be on top of that, so GUID number is better. All “normal” brands have that, at least with new server hardware. In this case I’m deploying HP Servers and they have iLO which is basically an other name for IPMI. In the case of iLO it is rather easy to access that information, you don’t even need to be authenticated, all the information we need is there (https://deploymentbunny.com/2013/12/18/nice-to-know-getting-hardware-infoilo-data-using-native-powers…) […]

  3. hi!
    your example URL has a typo in it (the second “?” should be a “=”):
    http://IPaddress/xmldata?item?All
    should read
    http://IPaddress/xmldata?item=All

    KR
    Guenther

  4. We can try this approach as well, please follow the link –
    https://geekeefy.wordpress.com/2015/03/25/powershell-how-to-find-server-ilo-ip-addresses-on-your-network/

  5. anonymous116 said

    Hi Mike,

    Thank you for posting your script. I have been searching hi and low looking for a way to get HP iLO IP and MAC addresses but have not found anything that met my needs. Your script included.

    My problem was that I am working with older machines that use iLO and iLO 2. Also, on most of the machines, I did not know the IP address of the iLO to be able to run your script against it. What I needed was something that would work if I only had the server name (OS hostname). I finally managed to come up with something that worked for me and because it took me so long to complete this solution I thought that I would add it to your post in case it can save someone else out there some time.

    My solution assumes that the server OS has hponcfg.exe installed in its default location of C:\Program Files\HP\HPONCFG\.

    With this in mind, if you were to log on to the server and execute the command:

    C:\Program Files\HP\HPONCFG\hponcfg.exe /f C:\Program Files\HP\HPONCFG\GetNet.txt

    Where GetNet.txt is a simple text file located in the same directory as hponcfg.exe and containing the following lines of text:

    you will get a result similar to the following:

    C:\Program Files\HP\hponcfg>hponcfg.exe /f GetNet.txt
    Firmware Revision = 1.94 Device type = iLO Driver name = CpqCiDrv

    Script succeeded

    This information provides both the IP and the MAC address of the iLO. Now to write a Powershell script to utilize this process.

    # Create a drive mapping to the remote hponcfg folder and copy the GetNet.txt file to that folder
    New-PSDrive -Name RemoteHPoncfg -PSProvider FileSystem -Root “\\$strServerName\C$\Program Files\HP\hponcfg”
    cd RemoteHPoncfg:\
    cp C:\Scripts\GetInfo\GetNet.txt .\
    # Now that the file has been copied, don’t forget to remove the drive mapping
    cd c:
    Remove-PSDrive RemoteHPoncfg

    # If you are executing this script within a loop of multiple servers you should also initialize your variables to NULL for each iteration of the loop.
    $strILOIPReturnString=$null
    $strILOIP=$null
    $strILONAMEReturnString=$null
    $strILONAME=$null
    $strILODOMAINReturnString=$null
    $strILODOMAIN=$null
    $strILOMACReturnString=$null
    $strILOMAC=$null
    $strILOFQDN = $null

    # Remotely execute the hponcfg command using psexec.exe. Because I was working with older OSs (Win2000 and Server 2003) I could not use the
    # built-in powershell method of executing remote commands.
    if (($strILOGetNETReturnString = (&C:\bin\pstools\psexec.exe -accepteula \\$strServerName “C:\Program Files\HP\hponcfg\hponcfg.exe” /f “C:\Program Files\HP\hponcfg\GetNet.txt”) 2> $null) -match “Script succeeded”)
    {

    # Parse out the values that you want. I wanted IP address, Name, Domain and MAC address.
    # I put the regex parsing within a test for NOT NULL because some of the older iLOs did not have results for all values (EG: MAC was missing on iLO v1)

    $strILOIPReturnString = $strILOGetNETReturnString | Select-String -Pattern “<IP_ADDRESS VALUE=" -SimpleMatch
    if($strILOIPReturnString -ne $null) {$strILOIP = ([regex]::Match($strILOIPReturnString, '(?<=")(.+)(?=")')).Value}

    $strILONAMEReturnString = $strILOGetNETReturnString | Select-String -Pattern "<DNS_NAME VALUE=" -SimpleMatch
    if ($strILONAMEReturnString -ne $null) {$strILONAME = ([regex]::Match($strILONAMEReturnString, '(?<=")(.+)(?=")')).Value}

    $strILODOMAINReturnString = $strILOGetNETReturnString | Select-String -Pattern "<DOMAIN_NAME VALUE="-SimpleMatch
    if ($strILODOMAINReturnString -ne $null) {$strILODOMAIN = ([regex]::Match($strILODOMAINReturnString, '(?<=")(.+)(?=")')).Value}

    $strILOFQDN = $strILONAME + "." + $strILODOMAIN

    $strILOMACReturnString = $strILOGetNETReturnString | Select-String -Pattern "<MAC_ADDRESS VALUE=" -SimpleMatch
    if ($strILOMACReturnString -ne $null) {$strILOMAC = ([regex]::Match($strILOMACReturnString, '(?<=")(.+)(?=")')).Value}
    }

    Now that you have these values stored in variables you can use them any way that you want.

    I hope that this may help someone else out there.

    Enjoy.

  6. […] to Mikael Nystrom from DeploymentBunny.com cause have added a few addition to his idea and script to work as per my […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.

Join 7,423 other followers

%d bloggers like this: