Solved

how to create a powershell report for the event log using convertto-html

Posted on 2013-06-19
5
805 Views
Last Modified: 2013-06-20
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
0
Comment
Question by:c7c4c7
5 Comments
 
LVL 39

Accepted Solution

by:
footech earned 250 total points
ID: 39260641
Just add a select statment to choose which properties you want to display.

$events = Get-Eventlog -logname system -EntryType Error -After ((Get-Date).Date.AddDays(-1))
$events | Group-Object -property source -noelement | Sort-Object -property count -descending | select Count,Name | ConvertTo-Html > c:\logs\new.html

Open in new window

0
 
LVL 40

Expert Comment

by:Subsun
ID: 39260645
You can use Select-Object (Select) to filter the properties..

For example..
$events = Get-Eventlog -logname system -EntryType Error -After ((Get-Date).Date.AddDays(-1))
$events | Group-Object -property source -noelement | Select Count,Name | Sort-Object -property count -descending |  convertto-html > c:\logs\new.html

Open in new window

0
 
LVL 39

Expert Comment

by:footech
ID: 39260659
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.
0
 
LVL 41

Expert Comment

by:Amit
ID: 39260661
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
0
 

Author Closing Comment

by:c7c4c7
ID: 39265013
Thanks for the help
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Join & Write a Comment

I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
Synchronize a new Active Directory domain with an existing Office 365 tenant
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now