Get iDRAC/ILO (aka Baseboard Management Controller) IP via PowerCLI

[Update: 1 report states issues w/ HP Gen9 systems.  Newer Dell, and older HP systems don't seem to have issues.  If you have a HP Gen9 system, feel free to contact me via google hangouts and/or twitter to start an interactive session and we can work through figuring out a workaround.]

Summary:
Needed a way to figure out what IP my HP iLO's / Dell iDrac's were configured with.  Ended up using an oldie, but a goodie script put together by Carter Shanklin.

PreReqs:

  1. Powershell 2+
  2. PowerCLI 4+
  3. Must have Port 443 (https) access to your ESXi hosts.
    • If firewalls are an issue you may have the option of running this from your vCenter if it's still running on Windows.  If it's the vApp, you'll need to open access to port 443.
  4. Download Carter's script
Short and Sweet:
$info = Get-VMHostWSManInstance -VMHost (Get-VMHost myESXiServer) -ignoreCertFailures -class OMC_IPMIIPProtocolEndpoint
$info
# You can remove the -ignoreCertFailures flags if your systems have trusted certs.
# This should return you the configuration of your iLO/iDrac, which includes IP address, like so:
$info.IPv4Address

Details:


To find out the CIM classes available you can reference VMware's API reference here:

Finding the class was no easy task.  I really couldn't find an efficient way to find the information I was looking for so I figured I'd post this as a reference for myself and anyone else needing this type information.

The script simplifies running the get-wsmaninstance cmdlet call to ESXi servers.  This is what the cmdlet string would have to look like if you weren't using the script:
# To get the $credential, you have to acquire a CIM ticket session from the host, you can see this in the script.  It's probably the part that requires the most work.
get-wsmaninstance -Authentication basic -ConnectionURI "https://myESXiServer/wsman" -Credential ($credential) -enumerate -Port 443 -UseSSL -SessionOption (New-WSManSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck) -ResourceURI "http://schema.omc-project.org/wbem/wscim/1/sim-schema/2/OMC_IPMIIPProtocolEndpoint"

13 comments:

Jau-Ling Chou said...

any idea if this can be done using the vSphere Perl SDK?

Chris Nakagaki said...

I imagine it's possible, but probably quite a bit more difficult. I would check with William Lam as he is way more fluent in Perl than I am.

John Hossbach said...

I tried this on a 6.0 Update 2 host and got the error below. I noticed that the /wsman URI-stem is returning 501 Method Not Implemented. Is there an update to this script?

Get-WSManInstance : The connection to the specified remote host was refused. Verify that the WS-Management service is
running on the remote host and configured to listen for requests on the correct port and HTTP URL.
At line:39 char:1
+ Get-WSManInstance -Authentication basic -ConnectionURI $uri -Credential $credent …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Get-WSManInstance], COMException
+ FullyQualifiedErrorId : Exception,Microsoft.WSMan.Management.GetWSManInstanceCommand

Chris Nakagaki said...

I'm not aware of anything changing. Just by going to the wsman URI and getting 501 simply means that you are hitting it, but it doesn't know what to do because you didn't pass any parameters. Is it only on 6.0U2 hosts that you are seeing the issue?

Anonymous said...

Hi Chris,

Yes, I can confirm that the script is not working on ESXi 6 hosts. The error which I got is below. Any suggestions on how to proceed further ??

Get-WSManInstance : The connection to the specified remote host was refused. Verify that the WS-Management service is running on the remote host and configured to listen for requests on the correct
port and HTTP URL.
At C:\users\USER2\desktop\wsman.psm1:44 char:17
+ Get-WSManInstance -Authentication basic -ConnectionURI $uri -Cre ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Get-WSManInstance], COMException
+ FullyQualifiedErrorId : Exception,Microsoft.WSMan.Management.GetWSManInstanceCommand

Get-WSManInstance : The connection to the specified
remote host was refused. Verify that the WS-Management service is running on the remote host and configured to listen for requests on the correct port and HTTP URL.
At C:\users\USER2\desktop\wsman.psm1:44 char:17
+ Get-WSManInstance -Authentication basic -ConnectionURI $uri -Cre ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (http://schema.o...rotocolEndpoint:Uri) [Get-WSManInstance], InvalidOperationException
+ FullyQualifiedErrorId : WsManError,Microsoft.WSMan.Management.GetWSManInstanceCommand

Pedro Alexandre said...

Try using the following class instead

CIM_IPProtocolEndpoint

More detailed information about this class on the following VMware url:

https://www.vmware.com/support/developer/cim-sdk/smash/ga/reference_html/CIM_IPProtocolEndpoint.html

Anonymous said...

Hey Pedro, All,

I replaced OMC_IPMIIPProtocolEndpoint with CIM_IPProtocolEndpoint but now the script is displaying all IP addresses which includes ILO IP address as wel. I tried to weed out other IP addresses by using if condition to search only for CreationClassName=OMC_IPMIIPProtocolEndpoint but it didn't work. I searched on Internet but couldn't find any leads on this. Any further idea on how to proceed ?

Chris Nakagaki said...

Are you getting an error or just nothing in return? I just checked against my ESXi 6.0U2 host and was able to pull back the information. What kind or hardware is your target?

Anonymous said...

Ran into the same error: Get-WSManInstance : The connection to the specified remote host was refused. Verify that the WS-Management service is running on the remote host and configured to listen for requests on the correct

We also had to replace OMC_IPMIIPProtocolEndpoint with CIM_IPProtocolEndpoint to resolve this issue - any idea what's causing this?

Chris Nakagaki said...

When you guys post, it would be helpful to know what hardware you are checking against. If CIM_IPProtocolEndpoint is working, then it makes me think something there might be a hardware specific issue.

I get information back from Dell iDRAC based servers. I get no info back from something like an Intel NUC, but that's the extent to which I have access to test against.

Anonymous said...

We are using hp proliant DL Gen 9 based servers with HP customized ESXi ISO. Did you get any further information on this ?

Anonymous said...

We are using hp proliant gen 9 based DL servers with HP cusotmized ESXi ISO image. Did you get any further information on this ?

Chris Nakagaki said...

I'm wondering if it's a specific problem w/ the HP Gen 9 systems. I haven't had issues w/ earlier revisions or w/ current Dell systems. Contact me through Google Hangouts so we can work through together.