In this post, I will take you through a PowerShell script that helps in setting up the password for HP Integrated Lights-Out (ILO) console.
All these years, I was under kind of wrong impression that HP ILO can be managed via web console and a few utilities given by HP. Today I realized that it can also be managed using other protocols like SSH and Telnet. The moment I learned about it, I started thinking how can I leverage this and automation HP ILO user account change process.
After a bit of Googling, I came across a nice document from HP that gives all you need for managing HP ILO via SSH, telnet, web, and other HP utilities. You can download a copy of “HP iLO2 Scripting and Command line Guide” from HP website (click here).
I authored below quick script after going through the document. The script replies on a utility called plink(click here to download) which you should download and place in System path to make this script work. Using plink.exe, the script creates a SSH connection to HP ILO IP/Name. This utilities takes username and password required for the ILO connection and then changes the password of the account your specified to the key you want.
Code:
[cmdletbinding()] param( [string]$ILOHostName, [string]$ILOLoginUser, [string]$ILOLoginUserpwd, [String]$ILOUser, [String]$ILOUserpwd, [string]$PlinkPath ) $ILOcmd = [String]::Format('{0} {1}@{2} -pw "{3}" "set /map1/accounts1/{4} password={5}" 2>&1', $PlinkPath, $ILOLoginUser, $ILOHostName, $ILOLoginUserpwd, $ILOUser, $ILOUserpwd) try { [array]$Output = Invoke-Expression $ILOcmd -ErrorAction Stop if($Output.Count -lt 2) { Write-Host "Failed to set ILO password. `nLastExitCode : $LASTEXITCODE`nResult : $Output" exit(1) } } catch { Write-Host "Failed to set ILO password. `nLastExitCode : $LASTEXITCODE`nResult : $Output" exit(1) } if($LASTEXITCODE -eq 0 -and $Output[1].Split("=")[1] -eq 0) { Write-Host "Password set successfully. `nLastExitCode : $LASTEXITCODE`nResult : $Output" } else { Write-Host "Failed to set password. `nLastExitCode : $LASTEXITCODE`nResult : $Output" }
Usage:
In the below example, I am creating SSH connection to HP ILO of host1 with a user name called Administrator and setting password for user account myilouser1. Please note that you need to pass ILO name or IP address of target host to ILOHostName parameter.
.\Set-ILOUserPassword.ps1 -ILOHostName host1ILO -ILOLoginUser administrator -ILOLoginUserpwd mypass -ILOUser myilouser1 -ILOUserpwd user1pwd -PlinkPath c:\temp\plink.exe
This is a simple script I have written to demonstrate that HP ILO password can be set easily using PowerShell. I request you to test the script properly in test/lab environment before trying in production. You can use this script by modifying a bit to create users, delete users etc. Please refer to the aforementioned HP documentation for examples on how to do variety of actions using SSH connection.
Hope this helps.