Created
June 28, 2021 13:40
-
-
Save K-Mistele/9e0469b9286e1e65e88b248856ed49ee to your computer and use it in GitHub Desktop.
Schedule a task as another user with PowerShell
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
$action=New-ScheduledTaskAction -Execute 'powershell.exe' -Argument '-windowstyle hidden -ep bypass C:\path\to\script.ps1'; | |
$trigger=New-ScheduledTaskTrigger -Once -At 'MM/DD/YYYY HH:MM:SS PM'; | |
Register-ScheduledTask -Action $action -Trigger $trigger -TaskName 'Launch' -User 'DOMAIN\username' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment