Friday, 4 September 2020

powershell 26 schedule task on remote computer

notepad++ is scheduled to run 1 min later from now on remote computer

notepad++ runs as scheduled

PS C:\Windows\System32> invoke-command -session $session -scriptblock {
>>     $action = New-ScheduledTaskAction -Execute 'C:\Program Files (x86)\Notepad++\notepad++.exe'
>>
>> $triggerNew-ScheduledTaskTrigger -Once -At (get-date).AddMinutes(1)
>>
>> Register-ScheduledTask -Action $action -Trigger $trigger -TaskName "start notepad++" -Description "powershell schedule to open notepad++"
>> }

TaskPath                                       TaskName                          State      PSComputerName
--------                                       --------                          -----      --------------

#delete scheduled task on remote
PS C:\Windows\System32> invoke-command -session $session -scriptblock {
>>     Get-ScheduledTask -TaskName "start notepad++" | Unregister-ScheduledTask -Confirm:$false
>> }

task scheduler

No comments:

Post a Comment