|
| 1 | +Function Get-MDTIssues{ |
| 2 | + $eventLog = Get-EventLog -LogName Application -Source MDT_Monitor -EntryType Warning,Error |
| 3 | + $eventLog.Message | ForEach-Object {$Event = $_ -replace "\s\{2}" -split 'for Computer ' -split ': ' |
| 4 | + New-object psobject -property @{ |
| 5 | + Computer = $($Event[1]) |
| 6 | + Notification = $($Event[0]) |
| 7 | + Message = $($Event[2]) |
| 8 | + } |
| 9 | + } |
| 10 | +} |
| 11 | + |
| 12 | +#Header |
| 13 | +#It is possible to use CSS instead, i'm just to lazy |
| 14 | +$Head = "<style>" |
| 15 | +$Head = $Head + "BODY{background-color:peachpuff;}" |
| 16 | +$Head = $Head + "TABLE{border-width: 2px;border-style: solid;border-color: black;border-collapse: collapse;}" |
| 17 | +$Head = $Head + "TH{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:thistle}" |
| 18 | +$Head = $Head + "TD{border-width: 1px;padding: 0px;border-style: solid;border-color: black}" |
| 19 | +$Head = $Head + "</style>" |
| 20 | + |
| 21 | +#Title |
| 22 | +$Title = "Deployment Issues" |
| 23 | + |
| 24 | +#Converting output to HTML |
| 25 | +$Output = Get-MDTIssues | Select @{n='Link';e={"<a href='$($_.Computer)'>$($_.Computer)</a>"}},Notification,Message | Sort-Object -Property Link | |
| 26 | +ConvertTo-Html ` |
| 27 | +-Title $Title ` |
| 28 | +-Head $Head ` |
| 29 | +-Body (Get-Date -UFormat "%Y-%m-%d - %T ") ` |
| 30 | +-PreContent "<H2>Deployment Status for: $ENV:COMPUTERNAME </H2><P>Generated by Power of the Shell</P>" ` |
| 31 | +-PostContent "<P>For details, contact support@internet.com</P>" ` |
| 32 | +-Property Link,Notification,Message |
| 33 | + |
| 34 | +#Converting HTML Output, since Convertto-html don't like HTML and mess it up |
| 35 | +$OutputMod = $Output | ` |
| 36 | +ForEach {$_ -replace "<a href='","<a href=http://$ENV:COMPUTERNAME/Logs/"} | ` |
| 37 | +ForEach {$_ -replace ''>','>'} | ` |
| 38 | +ForEach {$_ -replace '</a>','</a>'} |
| 39 | +$OutputMod > C:\MDTWeb\MDTIssues.htm |
0 commit comments