我的脚本类似于-
$action = New-ScheduledTaskAction -Execute "BolusDemoDataGenerator.BAT"
$TaskStartTime = [datetime]::Now.AddMinutes(2)
$trigger = New-ScheduledTaskTrigger -At $TaskStartTime -Once
$setting = New-ScheduledTaskSettingSet
$inputTask = -action $action -trigger $trigger -settings
Register-ScheduledTask BatchRunTask -InputObject $inputTask
但是我遇到了一个错误
New-ScheduledTaskAction : The term 'New-ScheduledTaskAction' is not
recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or if a
path was included, verify that the path is
correct and try again.
At C:\Users\abc\Desktop\hi.ps1:1 char:11
+ $action = New-ScheduledTaskAction -Execute "BolusDemoDataGenerator.BAT"
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (New-ScheduledTaskAction:String)
[], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
我不确定出了什么问题,我尝试执行这个PowerShell脚本来创建一个任务计划程序,以便在桌面上执行一个批处理文件。
$PSVersionTable.PSVersion
来确定版本号。 - ItchydonImport-Module ScheduledTasks
。 - Itchydon