Skip to content

Instantly share code, notes, and snippets.

@Ciantic
Last active February 28, 2023 08:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ciantic/fd676539018730f1db951bc80ac1d2a4 to your computer and use it in GitHub Desktop.
Save Ciantic/fd676539018730f1db951bc80ac1d2a4 to your computer and use it in GitHub Desktop.
Run powershell command only once, scheduled
$t = New-ScheduledTaskTrigger -Once -At (get-date).AddSeconds(10); $t.EndBoundary = (get-date).AddSeconds(60).ToString('s'); Register-ScheduledTask -Force -TaskName JustTrying -Action (New-ScheduledTaskAction -Execute "powershell.exe" -Argument '-NoProfile -WindowStyle Hidden -command "& {dir}"') -Trigger $t -Settings (New-ScheduledTaskSettingsSet -DeleteExpiredTaskAfter 00:00:01)
@ReneNyffenegger
Copy link

Thanks for this gist, I was searching high and low to find something like that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment