5
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Powershellでタスクスケジューラ登録

Last updated at Posted at 2018-01-24

#Powershellでタスクスケジュールを登録するためのメモ

深夜3時にIEを起動するだけのタスクスケジュールの登録です。
※下のUserがkotetsu75になっている2か所は適宜、お使いのユーザー名に変更してください。


$User = New-ScheduledTaskPrincipal -UserId kotetsu75 -LogonType Password
$Act = New-ScheduledTaskAction -Execute "C:\Program Files\internet explorer\iexplore.exe"
$Time = New-ScheduledTaskTrigger -Once -At 3am
$Task = New-ScheduledTask -Trigger $Time -Principal $User -Action $Act
Register-ScheduledTask -InputObject $Task -TaskName "test" -TaskPath \ -User kotetsu75

Linuxだとcronで超簡単にできるのに。。。

##無効化するには

Disable-ScheduledTask test

##有効化するには

Enable-ScheduledTask test

##実行する

Start-ScheduledTask test

##終了する

Stop-ScheduledTask test

#補足:タスクスケジューラに関連するコマンド一覧表示

Get-Command | ? Name  -match "ScheduledTask"

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Function        Disable-ScheduledTask                              1.0.0.0    ScheduledTasks
Function        Enable-ScheduledTask                               1.0.0.0    ScheduledTasks
Function        Export-ScheduledTask                               1.0.0.0    ScheduledTasks
Function        Get-ClusteredScheduledTask                         1.0.0.0    ScheduledTasks
Function        Get-ScheduledTask                                  1.0.0.0    ScheduledTasks
Function        Get-ScheduledTaskInfo                              1.0.0.0    ScheduledTasks
Function        New-ScheduledTask                                  1.0.0.0    ScheduledTasks
Function        New-ScheduledTaskAction                            1.0.0.0    ScheduledTasks
Function        New-ScheduledTaskPrincipal                         1.0.0.0    ScheduledTasks
Function        New-ScheduledTaskSettingsSet                       1.0.0.0    ScheduledTasks
Function        New-ScheduledTaskTrigger                           1.0.0.0    ScheduledTasks
Function        Register-ClusteredScheduledTask                    1.0.0.0    ScheduledTasks
Function        Register-ScheduledTask                             1.0.0.0    ScheduledTasks
Function        Set-ClusteredScheduledTask                         1.0.0.0    ScheduledTasks
Function        Set-ScheduledTask                                  1.0.0.0    ScheduledTasks
Function        Start-ScheduledTask                                1.0.0.0    ScheduledTasks
Function        Stop-ScheduledTask                                 1.0.0.0    ScheduledTasks
Function        Unregister-ClusteredScheduledTask                  1.0.0.0    ScheduledTasks
Function        Unregister-ScheduledTask                           1.0.0.0    ScheduledTasks
5
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?