Skip to Content

PowerShell - Find iLO on a subnet

Recently we had a need to find the versions of HP iLO on all our servers. Finding out through SIM can be challenging so we could log onto each server which was unappealing. I did some searches and could only find a script for scanning based on BASH so I thought I would give it a go in PowerShell. I am sure there are ways to tighten it up but it was fun to do.

I've only run it in PowerShell v2 and it requires the BSonPosh module.

For the web/xml extracting part I found this thread useful.

Things to do would be to use Test-Port to test each IP address for 17988 and limit the addresses of the subnet to that. In our environment we have subnets dedicated iLO so I didn't worry to much about the errors. I have no idea when I will get to that and this was a quick and dirty way to get the information we needed.

# ============================================================================
#    NAME: find-ilo.ps1
#  AUTHOR: Steven Peck
#  DATE  : 2010.01.22
# COMMENT: Find ILO's on subnet
#  SOURCE: blog.nachotech.com/?p=63
#REQUIRES: Test-Subnet from BSonPosh module, Tested only in PowerShell v2
#          code.msdn.microsoft.com/bsonposh
# ============================================================================

$objResult = @()
$subnet = Ping-Subnet -IP 192.168.1.0 -Netmask 255.255.254.0
foreach ($ip in $subnet) {
  [System.Xml.XmlDocument] $xd = new-object System.Xml.XmlDocument
  $url = "http://$ip/xmldata?item=ALL"
  $rawxml = (new-object System.Net.WebClient).DownloadString($url)
  $xd = $rawxml
 
  $ilo = new-object System.Object
  $ilo | add-member -MemberType NoteProperty -Name iloIP -value $ip
  $ilo | add-member -MemberType NoteProperty -Name iloHW $xd.RIMP.MP.PN
  $ilo | add-member -MemberType NoteProperty -Name iloFW $xd.RIMP.MP.FWRI
  $ilo | add-member -MemberType NoteProperty -Name ServerSN $xd.RIMP.MP.SN
  $ilo | add-member -MemberType NoteProperty -Name ServerModel $xd.RIMP.HSI.SPN
 
  $objResult += $ilo
 
}
$objResult




Warning: Table './d_blk6/accesslog' is marked as crashed and last (automatic?) repair failed query: statistics_exit /* Anonymous : statistics_exit */ INSERT INTO accesslog (title, path, url, hostname, uid, sid, timer, timestamp) values('', 'node/763', '', '38.107.191.103', 0, '81145ff64978296f1e9d3cbe40321a40', 40, 1280410277) in /home/sepeck/public_html/blkmtn.org/includes/database.mysqli.inc on line 128