#Powershell and ConvertTo-Html

Every day I use powershell its a school day, I learn something new!

So I use powershell at lot to create html pages from cmdlets.  ConvertTo-Html is a god send and make this a hell of a lot easier. So lets take an easy one:

Get-Service ZuneNetworkSvc

Status   Name               DisplayName
——   —-               ———–
Stopped  ZuneNetworkSvc     Zune Network Sharing Service

now convert it to html

Get-Service ZuneNetworkSvc | ConvertTo-Html -Fragment

Name RequiredServices CanPauseAndContinue CanShutdown CanStop DisplayNa me DependentServices MachineName ServiceName ServicesDependedOn ServiceHandle</ th> Status ServiceType Site Container
ZuneNetworkSvc System.ServiceProcess.ServiceController[] False False False Zune Network Sharing Service System.ServiceProcess.ServiceController[] . ZuneNetworkSvc System.ServiceProcess.ServiceController[]   Stopped Win32OwnProcess    

That cool, but a bit painful as it’s quite wide. Found this today the –As parameter!

Get-Service ZuneNetworkSvc | ConvertTo-Html –Fragment –As List

Name: ZuneNetworkSvc
RequiredServices: System.ServiceProcess.ServiceController[]
CanPauseAndContinue: False
CanShutdown: False
CanStop: False
DisplayName: Zune Network Sharing Service
DependentServices: System.ServiceProcess.ServiceController[]
MachineName: .
ServiceName: ZuneNetworkSvc
ServicesDependedOn: System.ServiceProcess.ServiceController[]
ServiceHandle:  
Status: Stopped
ServiceType: Win32OwnProcess
Site:  
Container:  

It just get better and better.  Check out some of the other parameters here: http://technet.microsoft.com/en-us/library/dd347572.aspx

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.