Skip to content

Instantly share code, notes, and snippets.

@lansalot
Last active December 2, 2021 16:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lansalot/22a5ae9fa0114b1003be9db1d56589bf to your computer and use it in GitHub Desktop.
Save lansalot/22a5ae9fa0114b1003be9db1d56589bf to your computer and use it in GitHub Desktop.
# 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