Windows: Read the IP Address of a BMC Board

Most of the Serversystems have a Baseboard Management Controller (BMC) integrated for maintenace and management tasks.

Typical functions are, indepentend from the running operating system:

  • Shutdown and reboot
  • Switch Power On and Off
  • KVM (Keyboard, Video, Mouse) redirection
  • Hardware monitoring
  • USB redirection, connect the local DVD Drive to the Server over a LAN connection
  • and much more…

Usually, the BMC has its own LAN Interface and therefore an own IP Address.

The IP Address of the BMC can be read by the MICROSOFT_IPMI WMI Class in Namespace root/wmi.  Since Server 2008 the WMI IPMI Provider Class is shipped with the operating system. In Windows Server 2003 R2 you must add this manually:

Go to Control Panel, Add/Remove System Components and install the Hardware Management feature under Management and Monitoring Tools.

The advantage of using the Microsoft WMI class is that this works manufacturer indepentent. Means it doesn’t matters wether the BMC, for example, is a Fujitsu iRMC or a HP iLO board.

The following script reads the IP Address, Subnet mask and MAC Address of the first BMC found in the system.


# Get the Class instance
$oIPMI=Get-WmiObject -Namespace root\WMI -Class MICROSOFT_IPMI
# Some constants
# <a title="Microsoft In Band Management" href="http://gallery.technet.microsoft.com/scriptcenter/In-Band-Management-using-88e221b8" target="_blank">Source</a>
[byte]$BMCResponderAddress = 0x20
[byte]$GetLANInfoCmd = 0x02
[byte]$GetChannelInfoCmd = 0x42
[byte]$SetSystemInfoCmd = 0x58
[byte]$GetSystemInfoCmd = 0x59
[byte]$DefaultLUN = 0x00
[byte]$IPMBProtocolType = 0x01
[byte]$8023LANMediumType = 0x04
[byte]$MaxChannel = 0x0b
[byte]$EncodingAscii = 0x00
[byte]$MaxSysInfoDataSize = 19

If you have administrator rights this works also on a remote machine. Just add the -ComputerName parameter when you get the WMI Class instance

$oIPMI=Get-WmiObject -Namespace root\WMI -Class MICROSOFT_IPMI -ComputerName RemoteComputer

Finding the first LAN Channel

[byte[]]$RequestData=@(0)
$oMethodParameter=$oIPMI.GetMethodParameters("RequestResponse")
$oMethodParameter.Command=$GetChannelInfoCmd
$oMethodParameter.Lun=$DefaultLUN
$oMethodParameter.NetworkFunction=0x06
$oMethodParameter.RequestData=$RequestData
$oMethodParameter.RequestDataSize=$RequestData.length
$oMethodParameter.ResponderAddress=$BMCResponderAddress
# http://msdn.microsoft.com/en-us/library/windows/desktop/aa392344%28v=vs.85%29.aspx
$RequestData=@(0)
[Int16]$iLanChannel=0
[bool]$bFoundLAN=$false
for(;$iLanChannel -le $MaxChannel;$iLanChannel++){
	$RequestData=@($iLanChannel)
	$oMethodParameter.RequestData=$RequestData
	$oMethodParameter.RequestDataSize=$RequestData.length
	$oRet=$oIPMI.PSBase.InvokeMethod("RequestResponse",$oMethodParameter,(New-Object System.Management.InvokeMethodOptions))
	#$oRet
	if($oRet.ResponseData[2] -eq $8023LANMediumType){
		$bFoundLAN=$true
		break;
	}
}

If a LAN Channel is found get the Network parameters


$oMethodParameter.Command=$GetLANInfoCmd
$oMethodParameter.NetworkFunction=0x0c
if($bFoundLAN){
	$RequestData=@($iLanChannel,3,0,0)
	$oMethodParameter.RequestData=$RequestData
	$oMethodParameter.RequestDataSize=$RequestData.length
	$oRet=$oIPMI.PSBase.InvokeMethod("RequestResponse",$oMethodParameter,(New-Object System.Management.InvokeMethodOptions))
	write-host ("IP Address:     "+$oRet.ResponseData[2]+"."+$oRet.ResponseData[3]+"."+$oRet.ResponseData[4]+"."+ $oRet.ResponseData[5] )
	$RequestData=@($iLanChannel,6,0,0)
	$oMethodParameter.RequestData=$RequestData
	$oMethodParameter.RequestDataSize=$RequestData.length
	$oRet=$oIPMI.PSBase.InvokeMethod("RequestResponse",$oMethodParameter,(New-Object System.Management.InvokeMethodOptions))
	write-host ("Subnet Mask:    "+$oRet.ResponseData[2]+"."+$oRet.ResponseData[3]+"."+$oRet.ResponseData[4]+"."+ $oRet.ResponseData[5] )
	$RequestData=@($iLanChannel,5,0,0)
	$oMethodParameter.RequestData=$RequestData
	$oMethodParameter.RequestDataSize=$RequestData.length
	$oRet=$oIPMI.PSBase.InvokeMethod("RequestResponse",$oMethodParameter,(New-Object System.Management.InvokeMethodOptions))
	# Format http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx
	write-host ("MAC Address:    "+("{0:x2}:{1:x2}:{2:x2}:{3:x2}:{4:x2}:{5:x2}" -f $oRet.ResponseData[2], $oRet.ResponseData[3],$oRet.ResponseData[4], $oRet.ResponseData[5], $oRet.ResponseData[6], $oRet.ResponseData[7]))
}

Have fun
Michael

References
MICROSOFT_IPMI WMI Provider
In-Band Management using IPMI and PowerShell

Read BMC network parameters
3.1 KiB
1611 Downloads
Details...

2 thoughts on “Windows: Read the IP Address of a BMC Board”

  1. Hi Michael, just wanted to thank you for this post, it’s fantastic and it helped me a great deal when trying to cleanup and standardize our hardware inventory, with this data I was able to break into make/model and start recovering access to the OOBM management homepages, which in turn saves money as we don’t have to reach out to local hands to help us out as often. I blogged about your script and made some edits to make it into a tool my colleagues can use and anyone else can edit as they see fit.

    Once again, thank you, it’s because of people like you that share this information that others like me can move forward.

Leave a Reply