Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
HP ilo powershell interface
#enter ilo IP address here
$ilourl = ""
$jsonpage = $ilourl + "/json/login_session"
#disable certificate check
add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
return true;
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
#first, login and get session cookie in $ws
$postParams = @{
'method' = "login"
'user_login' = "administrator"
'password' = "ilopassword"
$postParams = $postParams | ConvertTo-Json
$var = Invoke-RestMethod -Method Post -Uri $jsonpage -Body $postParams -sessionvariable ws
$session = $var.session_key
#get current power state
$powerpage = $ilourl + "/json/host_power"
$var = Invoke-RestMethod -Method get -Uri $powerpage -WebSession $ws
#soft press the button (clean shutdown or boot or whatever)
$postParams = @{
'method' = "press_power_button"
'session_key' = $session
$postParams = $postParams | ConvertTo-Json
$custHeaders = @{ "X-Auth-Token"= $session };
$var = Invoke-RestMethod -Method post -Uri $powerpage -Body $postParams -WebSession $ws -Headers $custHeaders
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.