Advertisement
Guest User

Untitled

a guest
Apr 25th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. #requires -module ScheduledTasks
  2.  
  3. #update PowerShell help via a Scheduled Task
  4. $cred = Get-Credential "$env:USERDOMAIN\$env:USERNAME"
  5.  
  6. # for Windows PowerShell
  7. # $action = New-ScheduledTaskAction -execute powershell.exe -argument '-noprofile -command "&{Update-Help -force}"'
  8. $actionparams = @{
  9. execute = 'pwsh.exe'
  10. argument = '-nologo -noprofile -noninteractive -command "&{Update-Help -force}"'
  11. }
  12. $action = New-ScheduledTaskAction @actionparams
  13.  
  14. $params = @{
  15. TaskName = "Monthly PowerShell Core Help Update"
  16. TaskPath = "\Microsoft\Windows\PowerShell"
  17. Trigger = New-ScheduledTaskTrigger -At 8:00AM -Weekly -WeeksInterval 4 -DaysOfWeek Monday
  18. Action = $action
  19. User = $cred.UserName
  20. Password = $cred.GetNetworkCredential().Password
  21. Runlevel = "Highest"
  22. }
  23.  
  24. Register-ScheduledTask @params
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement