Created
August 11, 2017 09:58
-
-
Save hclpandv/79a23039599082616e53806270a91cfa to your computer and use it in GitHub Desktop.
Services Report from
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Function Get-ScriptDirectory | |
| { | |
| $Invocation = (Get-Variable MyInvocation -Scope 1).Value | |
| Split-Path $Invocation.MyCommand.Path | |
| } | |
| cd (Get-ScriptDirectory) | |
| $Header = @" | |
| <style> | |
| TABLE {border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;width: 60%} | |
| TH {border-width: 1px;padding: 3px;border-style: solid;border-color: black;background-color: #6495ED;} | |
| TD {border-width: 1px;padding: 3px;border-style: solid;border-color: black;} | |
| p {color: #ccc;} | |
| </style> | |
| <title> | |
| CMS Services Report post wrapper Installation | |
| </title> | |
| "@ | |
| #$targetmachines = "vm00000001", "vm00000002", "vm00000003" | |
| $targetmachines = Get-Content .\targetmachines.txt | |
| #$targetmachine = (gc Env:\COMPUTERNAME) | |
| $Pre = "Report Run at : " + (Get-Date) | |
| $Post = "<br><p>© Maintained Scripting Team<p>" | |
| $Body = "<H2>Services Report post machine Build</H2> " | |
| $ConfigFile = ".\config.csv" | |
| foreach($targetMachine in $targetmachines) | |
| { | |
| $obj = @() | |
| foreach($row in Import-Csv $ConfigFile ) | |
| { | |
| $u = Get-Service -ComputerName $targetmachine| Where-Object {$_.DisplayName -eq $row.DisplayName} | |
| $Obj += $u | |
| } | |
| $obj | Select-Object Name, DisplayName, status, Machinename | ConvertTo-HTML -Head $Header -Body $Body -PreContent $Pre -PostContent $Post | foreach {if($_ -like "*<td>Running</td>*"){$_ -replace "<tr>", "<tr bgcolor=green>"}elseif($_ -like "*<td>Stopped</td>*"){$_ -replace "<tr>", "<tr bgcolor=red>"}else{$_}} > .\ServicesReport_$targetmachine.html | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment