Anyway, my "before I read what the expert says" entry is as follows:
Get-EventLog "Application" -ComputerName localhost -EntryType error | Group-Object -Property "Source" | Sort-Object -Property "Count" -Descending | Format-Table -Property "Count","Name" -AutoSize
Then I could quite simply just add the following to the end to write the output to a file:
| Out-File
1 comment:
Using the -NoElement parameter with Group-Object would prevent you from having to use a Format cmdlet to remove the Group column.
PS [MikeFRobbins.com] >help group-object -parameter noelement
-NoElement []
Omits the members of a group from the results.
Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
Consider using $Env:ComputerName instead of localhost (this is something I learned during the scripting games).
Here's the script I submitted for this one:
http://2012sg.poshcode.org/3910
And the blog I wrote about it:
http://mikefrobbins.com/2012/04/17/finding-application-errors-2012-powershell-scripting-games-beginner-event-5/
Mike F Robbins
http://mikefrobbins.com
Post a Comment