Tuesday, April 1, 2014

Working with HP ILO using PowerShell

Hi,

We needed to change password for one user for some hundreds of ESXi servers and task was distributed among the team and each person got nearly 50 servers. If you know me there was no way(may be last way) I was going to each ILO ip and change password for each ESXi server.

So I did a little google search and found that HP released a  module for HP ILO that can be downloaded from here HP ILO Cmdlets.     And i just want to clear that this module does not depend on what is the operating system installed on target server, it may be Unix, ESXi or Windows, it does not matter.

HP ILO Cmdlets support ILO v3 and ILO v4 (ILO v1 and ILO v2 are not supported) and you need at least powershell v2 to get this module to work(infact Powershell v1 does not support any Module, only PSSnapins)

After installing you will be getting a powershell module that you can findout by using
PS > Get-Module -ListAvailable



Once you are able to see the module, import the module in current session using
PS > Import-Module HPiLOCmdlets

Best part it this module is a script module, so you can just go to the module where it is installed and you can open HPiLOCmdlets.psm1 in notepad and find out how all fucntions are defined in module.

 












And it give you total of 110 Functions to work with.





So back to my problem, fortunately most of our servers were HP, so I took the charge of task and use below  command to reset the user

PS>Get-Content Servers.txt | foreach{ Set-HPiLOUser -Username username -Password password -UserLoginToEdit testuser -NewPassword newpassword}

So i get all ILO ips from Servers.txt and pipe it to Set-HPiloUser function and here username and pasword are for logging into the ILO, testuser is the user for which we want to change the password and newpassword will be obviously new password you want to set.

Actually you can find better help (I agree, much better help) if you would use
PS > Help  Set-HPiLOUser -Full

You can do much more with Set-HPiLOUser and even more with whole module.




Happy Scripting!!!