Last active
December 2, 2021 16:42
-
-
Save lansalot/22a5ae9fa0114b1003be9db1d56589bf to your computer and use it in GitHub Desktop.
This file contains 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
# just in case the scheduled task runs before the NCSI check... we'll wait for an event to turn up. 5 minutes should be enough time to spot a recent reboot | |
Do { | |
$ev = get-winevent -filterhashtable @{LogName ="Microsoft-Windows-NCSI/Operational"; StartTime = (get-date).AddMinutes(-5)} -MaxEvents 1 -erroraction SilentlyContinue | |
Start-Sleep -Seconds 5 | |
} While ($null -eq $ev) | |
$x = [xml]$ev.toxml() | |
if (($x.event.eventdata.data| Where {$_.name -eq 'Capability'}).'#text' -eq 0) { | |
# we have a problem... tell a grown-up | |
Send-TeamsMessage -Uri "(teams webhook URL)" ` | |
-MessageTitle "URGENT!! WVD Host $(hostname) at (client) reporting no internet access" -MessageText "Please drain it, kick any users off and reboot it. Please acknowledge you've done that so not everyone jumps on. Cheers!" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment