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
|
$path = "\" #default
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Optional vars
|
||||||
|
if ($params.argument)
|
||||||
|
{
|
||||||
|
$argument = $params.argument
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$task = Get-ScheduledTask -TaskPath "$path" | Where-Object {$_.TaskName -eq "$name"}
|
$task = Get-ScheduledTask -TaskPath "$path" | Where-Object {$_.TaskName -eq "$name"}
|
||||||
|
|
||||||
|
@ -137,6 +143,13 @@ try {
|
||||||
else {
|
else {
|
||||||
$settings = New-ScheduledTaskSettingsSet
|
$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) ){
|
if ( ($state -eq "present") -and ($exists -eq $false) ){
|
||||||
$action = New-ScheduledTaskAction -Execute $execute
|
$action = New-ScheduledTaskAction -Execute $execute
|
||||||
|
@ -152,9 +165,7 @@ try {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Unregister-ScheduledTask -TaskName $name -Confirm:$false
|
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 -Principal $principal
|
||||||
Register-ScheduledTask -Action $action -Trigger $trigger -TaskName $name -Description $description -TaskPath $path -Settings $settings
|
|
||||||
$task = Get-ScheduledTask -TaskName $name
|
|
||||||
Set-Attr $result "msg" "Updated task $name"
|
Set-Attr $result "msg" "Updated task $name"
|
||||||
$result.changed = $true
|
$result.changed = $true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue