Hilfe zum Erstellen eines Skripts zum Abrufen eines HPOA-Server-Blade Integritätsbericht Das Problem ist, dass wenn ich abfragen Gesundheit in einem PSO-Objekt mit Feldern (IP, Health, Blades (@ {Blade1 ... Gesundheit} {Blade2 Gesundheit} {3})) ich möchte einen Bericht wie untenExcel-Bericht Formatierung in PowerShell
IP Bay Power Health
- --- ----- -----
10.3. 131.2 1 ein OK
2 ein OK
3 ein OK
4 Ein OK
5 On Degraded
Die Variablen werden wie folgt abgeleitet.
$ sstaInfo = {} | Wählen Sie IP, Bay, Power, Health und DeviceFailure aus.
$ sstaInfo.IP = $ ssta.IP (Gibt eine einzige IP-Ausgabe) $ sstaInfo.Bay = $ sstaBlades.Bay $ sstaInfo.Power = $ sstaBlades.Power $ sstaInfo .Health = $ sstaBlades.Health
Wie kann ich das funktionieren?
$ ssta Variable hat die folgende Ausgabe: @ {Power = On; CurrentWattageUsed = 480; Gesundheit = OK; UnitIdentificationLED = Aus; VirtualFan = 33%; DiagnosticStatus =; Schacht = 1} @ {Leistung = Ein; CurrentWattageUsed = 576; Gesundheit = OK; UnitIdentificationLED = Aus; VirtualFan = 47%; DiagnosticStatus =; Bay = 2}
#------------------------------------------------------------ Input Variable Definations
$HPOAServers [email protected](
[pscustomobject]@{Name='10.11.12.13'},
[pscustomobject]@{Name='10.11.12.14'}
)
$Username ="admin"
$Password ="admin"
#------------------------------------------------------------ Main Script Starts Here
# Function for connecting to OA and returning connection object on success
foreach ($HPOAServer in $HPOAServers) {
$con = Connect-HPOA $HPOAServer.Name -username $Username -password $Password
$report = @()
$ssta = Get-HPOAServerStatus -Bay All $con
$sstaBlade=$ssta.Blade
Write-Host $sstaBlade
Foreach ($sstaBlades in $sstaBlade) {
$i++
$sstaInfo = {} | Select IP, Bay, Power, Health, DeviceFailure
$sstaInfo.IP=$ssta.IP
$sstaInfo.Bay=$sstaBlades.Bay
$sstaInfo.Power=$sstaBlades.Power
$sstaInfo.Health=$sstaBlades.Health
$sstaInfo.DeviceFailure=$ssta.Blade.DiagnosticStatus.DeviceFailure
}
$report += $ssta | Select-Object -Property IP
$report += $ssta.Blade | Select-Object -Property Bay, Power, Health | Format-Table *
$report | out-file "HPOA_Health_Report.txt" -Append
}
Disconnect-HPOA $con
Das obige funktionierte wie ein Charme für mich :) –