3

Trying to figure out how to convert to HTML multiple service checks:

I have this script:

Get-service -Computername SERVER1 -Name *SERVICE1* | ConvertTo-Html -Body "<H2>Service 1 Check</H2> " -Property Name,Status 
Get-Service  -Computername SERVER2 -name *SERVICE2* | ConvertTo-Html -Body "<br><H2>Service 2 Check</H2> " -Property Name,Status | Out-File  c:\servicecheck.htm

Is this possible?

3
  • Check here - technet.microsoft.com/en-us/library/ff730936.aspx Commented May 14, 2013 at 14:54
  • I know how to do it, but just not for multiple get-service to output into one HTML file. Thanks though. Commented May 14, 2013 at 14:55
  • Modifying your question title then. Commented May 14, 2013 at 15:23

1 Answer 1

11

May be you can do something like this -

$Event = Get-EventLog -LogName Security -newest 100 | ConvertTo-HTML -Fragment 
$Process = Get-Process | ConvertTo-HTML -Fragment 
ConvertTo-HTML -Body "$Event $Process" -Title "Status Report" |  Out-File c:\StatusReport.html

NB: Replace $Event and $Process with your service cmdlets.

-Fragment [<SwitchParameter>] Generates only an HTML table. The HTML, HEAD, TITLE, and BODY tags are omitted.

Reference - http://technet.microsoft.com/en-us/magazine/hh127059.aspx

Sign up to request clarification or add additional context in comments.

1 Comment

So can I use -Fragment multiple times or just once? Thanks for the help worked great. Will be posting another Q soon if I can't figure it about how to use logic to give an OK or List the services not running and then colour code the response! :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.