Solved

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

Posted on 2013-06-19
5
898 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 40

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 40

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 43

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

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

Question has a verified solution.

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

A brief introduction to what I consider to be the best editor for PowerShell.
In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

707 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