Add support for command arguments
This commit is contained in:
parent
f1e8de2f67
commit
7ea34369f7
1 changed files with 14 additions and 3 deletions
|
@ -74,6 +74,12 @@ else
|
|||
$path = "\" #default
|
||||
}
|
||||
|
||||
# Optional vars
|
||||
if ($params.argument)
|
||||
{
|
||||
$argument = $params.argument
|
||||
}
|
||||
|
||||
try {
|
||||
$task = Get-ScheduledTask -TaskPath "$path" | Where-Object {$_.TaskName -eq "$name"}
|
||||
|
||||
|
@ -138,6 +144,13 @@ try {
|
|||
$settings = New-ScheduledTaskSettingsSet
|
||||
}
|
||||
|
||||
if ($argument) {
|
||||
$action = New-ScheduledTaskAction -Execute $execute -Argument $argument
|
||||
}
|
||||
else {
|
||||
$action = New-ScheduledTaskAction -Execute $execute
|
||||
}
|
||||
|
||||
if ( ($state -eq "present") -and ($exists -eq $false) ){
|
||||
$action = New-ScheduledTaskAction -Execute $execute
|
||||
Register-ScheduledTask -Action $action -Trigger $trigger -TaskName $name -Description $description -TaskPath $path -Settings $settings
|
||||
|
@ -152,9 +165,7 @@ try {
|
|||
}
|
||||
else {
|
||||
Unregister-ScheduledTask -TaskName $name -Confirm:$false
|
||||
$action = New-ScheduledTaskAction -Execute $execute
|
||||
Register-ScheduledTask -Action $action -Trigger $trigger -TaskName $name -Description $description -TaskPath $path -Settings $settings
|
||||
$task = Get-ScheduledTask -TaskName $name
|
||||
Register-ScheduledTask -Action $action -Trigger $trigger -TaskName $name -Description $description -TaskPath $path -Settings $settings -Principal $principal
|
||||
Set-Attr $result "msg" "Updated task $name"
|
||||
$result.changed = $true
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue