Get-BladeAndIloInfo.ps1 (zpäť na zoznam)
Zisťovanie informácií o nastaveniach napájania blade-u a overenie, či určitý účet existuje na iLO karte.
#SSH-SESSIONS download link: https://www.powershellgallery.com/packages/SSHSessions/2.1.3
$accountName = "admin"
$orig_pwd = "password"
$alt_pwd = "alt_password"
$powerList = "C:\temp\iLO_Check\powerList.csv"
$accList = "C:\temp\iLO_Check\accList.csv"
$powerLog = "C:\temp\iLO_Check\powerLog.csv"
$accLog = "C:\temp\iLO_Check\accLog.csv"
$powerLogHeader = "Blade;iLOIP;Power Regulator;"
$accLogHeader = "Blade;iLOIP;ecsadmin account;"
Import-Module ssh-sessions
Add-Content $powerLog $powerLogHeader
Add-Content $accLog $accLogHeader
$power = Import-Csv $powerList -Delimiter ";"
foreach ($item in $power) {
$iLOIP = $item.iLOIP
$blade = $item.Blade
$result = New-SshSession -ComputerName $iLOIP -Username $accountName -Password $orig_pwd
if ($result -notmatch "Successfully") {
$result = New-SshSession -ComputerName $iLOIP -Username $accountName -Password $alt_pwd
}
$power = Invoke-SshCommand -ComputerName $iLOIP -Command 'show /system1/oemhp_power1' #to check system power regulator 'oemhp_powerreg=max'
if ($power -match "oemhp_powerreg=max") {
$powerMax = "OK"
}
else {
$powerMax = "NOK"
}
if ($result -notmatch "Successfully") {
$powerMax = "can't connect"
}
$string = $blade + ";" + $iLOIP + ";" + $powerMax
Add-Content $powerLog $string
}
Remove-SshSession -RemoveAll
$acc = Import-Csv $accList -Delimiter ";"
foreach ($item in $acc) {
$iLOIP = $item.iLOIP
$blade = $item.Blade
$result = New-SshSession -ComputerName $iLOIP -Username $accountName -Password $orig_pwd
if ($result -notmatch "Successfully") {
$result = New-SshSession -ComputerName $iLOIP -Username $accountName -Password $alt_pwd
}
$account = Invoke-SshCommand -ComputerName $iLOIP -Command 'show /map1/accounts1' #to check accounts in iLO for 'other_admin'
if ($account -match "other_admin") {
$accountResult = "OK"
}
else {
$accountResult = "NOK"
}
if ($result -notmatch "Successfully") {
$accountResult = "can't connect"
}
$string = $blade + ";" + $iLOIP + ";" + $accountResult
Add-Content $accLog $string
}
Remove-SshSession -RemoveAll