Pages: [1]
Print
Author Topic: Looking for help on a small powershell issue  (Read 420 times)
bmmikee
Newbie
*
Posts: 9


View Profile Email
« on: March 22, 2010, 12:14:19 PM »

I'm using a reporting script that works very well.  When it reports on error messages from all hosts it just bunches them together in one block.  I'm wondering if its possible to seperate them on a per host basis?  As in list the individual host, then error messages and so forth.  This is the code that is being used to pull them:

###############################
# Errors the last 24 hours   #
###############################
# Get-VIEvent -Start (Get-Date).AddHours(-120) -Type Error | Format-Table CreatedTime, FullFormattedMessage -AutoSize | ConvertTo-Html -title "Errors the last five days" -body "<H2>Errors the last 5 days.</H2>" | Out-File -Append $filelocation
Get-VIEvent -Start (Get-Date).AddHours(-120) -Type Error | Select-object CreatedTime, FullFormattedMessage | ConvertTo-Html -title "Errors the last five days" -body "<H2>Errors the last 5 days.</H2>" | Out-File -Append $filelocation
Logged
esarakaitis
Administrator
Full Member
*****
Posts: 241


8223109 sack57@hotmail.com littleking57 rootinfortwayne
View Profile WWW Email
« Reply #1 on: March 23, 2010, 07:23:49 AM »

does it do the same thing when your not using convertto-html?
Logged
ewannema
Administrator
Newbie
*****
Posts: 30


View Profile WWW
« Reply #2 on: March 23, 2010, 10:38:14 AM »

To do what you want you need to extract the host property and then sort by it.  You can grab the records using a slight modification of your technique.

Code:
Get-VIEvent -Start (Get-Date).AddHours(-120) -Type Error | ForEach-Object {$_ | Select-Object CreatedTime, @{Name="Host"; Expression={$_.Host.Name}}, FullFormattedMessage} | Sort-Object -Property Host,CreatedTime

Note that not all events will be associated with hosts so that field will most likely be blank in that case.
Logged
Pages: [1]
Print
Jump to: