beautypg.com

Log processing examples – HP Scripting Tools for Windows PowerShell User Manual

Page 17

background image

IP : 192.168.1.3
HOSTNAME : isabella-vp2.company.net
STATUS_TYPE : WARNING
STATUS_MESSAGE : {Host power is already ON.}

IP : 192.168.1.1
HOSTNAME : ilohostbc.company.net
STATUS_TYPE : OK
STATUS_MESSAGE : OK
HOST_POWER : ON

IP : 192.168.1.3
HOSTNAME : isabella-vp2.company.net
STATUS_TYPE : OK
STATUS_MESSAGE : OK
HOST_POWER : ON

Because the items in the CSV file are named the same as the parameters, you can pipe the imported
object into the cmdlet and get the same results again as shown in the following script.

PowerShell script:

$path = ".\input1.csv"
$csv = Import-Csv $path
$rt = $csv | Set-HPiLOHostPower
$rt | Format-List
$rt = $csv | Get-HPiLOHostPower
$rt | Format-List

As demonstrated by the preceding examples, the methods available for providing input to a cmdlet
are very flexible. These same techniques can be used on most iLO cmdlets.

Log processing examples

The following examples demonstrate how to access iLO log data. In these examples, you want to
get a summary of the events in the iLO logs without having to view all the log events. The summary
enables you to focus on the details for specific types of events in the logs.

The following input CSV file and script create an event summary for two iLOs.

CSV input file:

Input3.csv:
Server,Username,Password
192.168.1.9,admin,admin123
192.168.1.14,admin,admin123

PowerShell script:

$path = ".\input3.csv"
$csv = Import-Csv $path
$rt = $csv | Get-HPiLOEventLog
#process the ilo event log returned from each iLO
foreach ($ilo in $rt) {
$ilo.IP + " has " + $ilo.EVENT.Count + " iLO log entries."
$sevs = $(foreach ($event in $ilo.EVENT) {$event.SEVERITY})
$uniqsev = $($sevs | Sort-Object | Get-Unique)
$sevcnts = $ilo.EVENT | group-object -property SEVERITY –noelement
"There are " + $uniqsev.Count + " type(s) of events in the iLO log.”
$sevcnts | Format-Table

Log processing examples

17