c7c4c7
asked on
how to create a powershell report for the event log using convertto-html
I am trying to convert the output of a powershell script to HTML but I'm having problems with the output of the Group-Object commandlet. It's giving me output that junks up the display and I can't figure how to get rid of it.
The original commandlet and the convertto-html is in the attachment. I want to get rid of the Value and Group Column.
Also please explain why your answer gets rid of the unwanted columns
Thanks for the help
convertohtml.txt
The original commandlet and the convertto-html is in the attachment. I want to get rid of the Value and Group Column.
Also please explain why your answer gets rid of the unwanted columns
Thanks for the help
convertohtml.txt
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
By default the Group-Object cmdlet only displays the Count and Name properties, but ConvertTo-HTML works on all the properties passed to it. By using the Select-Object cmdlet we can limit which properties to pass on.
Use this
$events = Get-Eventlog -logname system -EntryType Error -After ((Get-Date).Date.AddDays(- 1))
$events | Group-Object -property source -noelement | Sort-Object -property count -descending | ConvertTo-HTML count,name | Out-File c:\temp\new.html
Let me know, if that helps
$events = Get-Eventlog -logname system -EntryType Error -After ((Get-Date).Date.AddDays(-
$events | Group-Object -property source -noelement | Sort-Object -property count -descending | ConvertTo-HTML count,name | Out-File c:\temp\new.html
Let me know, if that helps
ASKER
Thanks for the help
For example..
Open in new window