RSS

VBScript to grab server names from a list of HP Blade enclosures

01 Aug

Challenge: How to get all blade’s server names (iLO name really) from a list of Enclosure’s IP address? This so far works only for HP Blade C series enclosure

set objArg = WScript.Arguments
if objArg.Count >= 4 then

  set WshShell = WScript.CreateObject("WScript.Shell")

  Encl_IP = objArg(0)
  Encl_Name = objArg(1)
  LogonID = objArg(2)
  LogonPWD = objArg(3)

  WshShell.run "telnet.exe -f .\" & Encl_Name & "_" _
   & Encl_IP & ".log " & Encl_IP
  WScript.Sleep 2000

  wshShell.AppActivate ("telnet.exe " & objArg(0))
  WshShell.SendKeys LogonID
  WshShell.SendKeys ("{Enter}")
  WScript.Sleep 1000

  wshShell.AppActivate ("telnet.exe " & objArg(0))
  WshShell.SendKeys LogonPWD
  WshShell.SendKeys ("{Enter}")
  WScript.Sleep 1000

  wshShell.AppActivate ("telnet.exe " & objArg(0))
  WshShell.SendKeys "SHOW SERVER LIST"
  WshShell.SendKeys("{Enter}")
  WScript.Sleep 1500

  wshShell.AppActivate ("telnet.exe " & objArg(0))
  WshShell.SendKeys "exit"
  WshShell.SendKeys ("{Enter}")
  WScript.Sleep 1500

  wshShell.AppActivate ("telnet.exe " & objArg(0))
  WshShell.SendKeys ("{Enter}")

  Set fso = CreateObject("Scripting.FileSystemObject")
  set f = fso.OpenTextFile(".\" & Encl_Name & "_" & Encl_IP & ".log")

  Is_SOL = false  'Is start of line?
  SvrInfo = ""
  do while not f.AtEndOfStream
    t = f.readline
    if instr(t,"Bay iLO Name ") > 0 then
      t = f.readline
      t = f.readline
      Is_SOL = true
    elseif instr(t,"Totals:") > 0 then
      Is_SOL = false
      exit do
    end if

    if Is_SOL then  'grab server name from current line
      t = mid(t,5,29) & vbTab & Encl_Name & vbTab & Encl_IP
      SvrInfo = t & vbCrLf & SvrInfo
    end if

  loop

  f.close

  set f1 = fso.OpenTextFile(".\ServerList.log",8,true)
  f1.Writeline SvrInfo
  f1.close

else

  Wscript.echo " "
  Wscript.echo "<encl. IP> <encl. name>  "
  Wscript.echo " "
  Wscript.echo "Log file for telnet session = <encl. name>_log.log"

end if
Advertisements
 
Leave a comment

Posted by on August 1, 2012 in Scripts, VBScripts

 

Tags: ,

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

 
%d bloggers like this: