很奇怪,我正在尝试使用描述注册计划任务,但它总是会抛出错误。
这很好用:
$Params = @{
Execute = 'Powershell.exe'
Argument = '-ExecutionPolicy Bypass
-File "\\Server\c$\Script.ps1"'
}
$Action = New-ScheduledTaskAction @Params
$Task = New-ScheduledTask -Action $Action
$Params = @{
InputObject = $Task
TaskPath = '\PowerShell scripts'
User = 'Domain.Net\Admin'
Password = 'Password'
}
Register-ScheduledTask @Params -TaskName 'Printer list' -Force
但是我从ISE使用intellisense添加描述的那一刻,就像这样:
Register-ScheduledTask @Params -TaskName 'Printer list' -Description "This is my description" -Force
它会抛出以下错误:
Register-ScheduledTask : Parameter set cannot be resolved using the specified named parameters.
我错过了一些明显的东西吗?
答案 0 :(得分:1)
超级愚蠢的我,你必须用New-SheduledTask
Cmdlet定义描述:
$Task = New-ScheduledTask -Action $Action -Description "This is my description"