Solved

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

Posted on 2013-06-19
5
837 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 42

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The article will show you how you can maintain a simple logfile of all Startup and Shutdown events on Windows servers and desktops with PowerShell. The script can be easily adapted into doing more like gracefully silencing/updating your monitoring s…
Microsoft Windows Server Update Service (WSUS) is free for everyone, but it lacks of some desirable features like send an e-mail to the administrator with the status of all computers on the WSUS server. This article is based on my PowerShell script …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

803 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