1.Get-command -moudle scheduledTask
2.get-
3.set-scheduledtask
Set-ScheduledTask [[-Password] <String>] [[-User] <String>] [[-Action] <CimInstance[]>] [[-TaskPath] <String>] [[-Settings] <CimInstance>] [[-Trigger] <CimInstance[]>] [-TaskName] <String> [-CimSession <CimSession[]>] [-ThrottleLimit <Int32>] [-AsJob] [<CommonParameters>]
4.添加一个task
$action_console="D:\ConsoleDemo\ConsoleTest\ConsoleTest\bin\Debug\netcoreapp3.1\ConsoleTest.exe" $TaskName = "powershellTask" $UserName ="namedemo" $UserPass="psw" $sset_n = New-ScheduledTaskSettingsSet -DontStopIfGoingOnBatteries -AllowStartIfOnBatteries $action_n = New-ScheduledTaskAction -Execute $action_console $trigger_n = New-ScheduledTaskTrigger -AtLogOn $task_n = New-ScheduledTask -Action $action_n -Trigger $trigger_n -Settings $sset_n Register-ScheduledTask $TaskName -InputObject $task_n -User $UserName -Password $UserPass -Force