Restart iBMC (Huawei)

Aus Wiki-WebPerfect
Version vom 21. September 2020, 12:44 Uhr von Admin (Diskussion | Beiträge)

(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)
Wechseln zu: Navigation, Suche
$Node = "<iBMC IP>"
$Headers = @{Authorization = "Basic <TOKEN>"} #region HTTP Basic Auth
 
 
#region SSL - Because of the unsigned certs in iBMC we have to trust all certs
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
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Ssl3, [Net.SecurityProtocolType]::Tls, [Net.SecurityProtocolType]::Tls11, [Net.SecurityProtocolType]::Tls12
 
 
#REST Call to find the Blade-Number
$Blade = ((Invoke-RestMethod -Uri "https://$Node/redfish/v1/Systems" -Method Get -Headers $headers -ErrorAction Continue).Members)."@odata.id" -split "/" | Select-Object -Last 1
 
#REST call to restart iBMC
$Body = @{ResetType = "ForceRestart"} | ConvertTo-Json
Invoke-WebRequest -Uri "https://$Node/redfish/v1/Managers/$Blade/Actions/Manager.Reset" -Method POST -Body $Body -Headers $Headers -ContentType "application/json" -UseBasicParsing