Skip to content

Instantly share code, notes, and snippets.

@NathanTheGr8
Created May 13, 2021 03:11
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 NathanTheGr8/e3e15ddce6c0201ace13791681c030c9 to your computer and use it in GitHub Desktop.
Save NathanTheGr8/e3e15ddce6c0201ace13791681c030c9 to your computer and use it in GitHub Desktop.
$argument = '/installtunnelservice "C:\Program Files\WireGuard\Data\Configurations\wg0.conf"'
$action = New-ScheduledTaskAction -Execute 'C:\Program Files\WireGuard\wireguard.exe' -Argument $argument
$principal = New-ScheduledTaskPrincipal -UserID "NT AUTHORITY\SYSTEM" -LogonType ServiceAccount -RunLevel Highest
$trigger = New-ScheduledTaskTrigger -AtStartup
$task = New-ScheduledTask -Action $action -Principal $principal -Trigger $trigger
Register-ScheduledTask "WireGuard" -InputObject $task -Force -TaskPath "Custom"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment