Powershell PSRemoting GUI app
remote GUI AP by Powershell
タスクスケジューラを使う。
function runtask($name, $ap){ $action = New-ScheduledTaskAction -Execute $ap $trigger = New-ScheduledTaskTrigger -Once -At '00:00' $task = Register-ScheduledTask -TaskName 'run calc' -Trigger $trigger -Action $action Start-ScheduledTask $task.TaskName return $task } function rmtask($name){ $task = Get-ScheduledTask | ? {$_.Name -like $name } if ($task){ Unregister-ScheduledTask $name } } ### main $remotehost = "ahiru" $remoteuser = "saba" $name = "run notepad" $ap = 'c:\windows\notepad.exe' enter-pssession $remotehost -credential $remoteuser $task = runtask($name, $ap) rmtask $task.TaskName exit-pssession
Enter-PSSession でパスワード入力を回避する方法は以前の記事参照。