Solved

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

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

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.

Question has a verified solution.

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

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
This article will help you understand what HashTables are and how to use them in PowerShell.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

895 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

20 Experts available now in Live!

Get 1:1 Help Now