Skip to content

Commit

Permalink
Build for Set-ValentiaScheduledTask
Browse files Browse the repository at this point in the history
  • Loading branch information
guitarrapc committed Dec 7, 2014
1 parent 592e554 commit d77b885
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 37 deletions.
79 changes: 44 additions & 35 deletions valentia/valentia.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4553,67 +4553,70 @@ function Set-ValentiaScheduledTask
param
(
[parameter(Mandatory = 0, Position = 0)]
[string]$execute,
[string]$Execute,

[parameter(Mandatory = 0, Position = 1)]
[string]$argument,
[string]$Argument = "",

[parameter(Mandatory = 1, Position = 2)]
[string]$taskName,

[parameter(Mandatory = 0, Position = 3)]
[string]$taskPath = "\",
[parameter(Mandatory = 0, Position = 2)]
[string]$WorkingDirectory = "",

[parameter(Mandatory = 1, Position = 3)]
[string]$TaskName,

[parameter(Mandatory = 0, Position = 4)]
[string]$TaskPath = "\",

[parameter(Mandatory = 0, Position = 5)]
[datetime[]]$ScheduledAt,

[parameter(Mandatory = 0, Position = 5, parameterSetName = "ScheduledDuration")]
[parameter(Mandatory = 0, Position = 6, parameterSetName = "ScheduledDuration")]
[TimeSpan[]]$ScheduledTimeSpan = ([TimeSpan]::FromHours(1)),

[parameter(Mandatory = 0, Position = 6, parameterSetName = "ScheduledDuration")]
[parameter(Mandatory = 0, Position = 7, parameterSetName = "ScheduledDuration")]
[TimeSpan[]]$ScheduledDuration = [TimeSpan]::MaxValue,

[parameter(Mandatory = 0, Position = 7, parameterSetName = "Daily")]
[parameter(Mandatory = 0, Position = 8, parameterSetName = "Daily")]
[bool]$Daily = $false,

[parameter(Mandatory = 0, Position = 8, parameterSetName = "Once")]
[parameter(Mandatory = 0, Position = 9, parameterSetName = "Once")]
[bool]$Once = $false,

[parameter(Mandatory = 0, Position = 9)]
[parameter(Mandatory = 0, Position = 10)]
[string]$Description,

[parameter(Mandatory = 0, Position = 10)]
[parameter(Mandatory = 0, Position = 11)]
[PScredential]$Credential = $null,

[parameter(Mandatory = 0, Position = 11)]
[parameter(Mandatory = 0, Position = 12)]
[bool]$Disable = $true,

[parameter(Mandatory = 0, Position = 12)]
[parameter(Mandatory = 0, Position = 13)]
[bool]$Hidden = $true,

[parameter(Mandatory = 0, Position = 13)]
[parameter(Mandatory = 0, Position = 14)]
[TimeSpan]$ExecutionTimeLimit = ([TimeSpan]::FromDays(3)),

[parameter(Mandatory = 0,Position = 14)]
[parameter(Mandatory = 0,Position = 15)]
[ValidateSet("At", "Win8", "Win7", "Vista", "V1")]
[string]$Compatibility = "Win8",

[parameter(Mandatory = 0,Position = 15)]
[parameter(Mandatory = 0,Position = 16)]
[ValidateSet("Highest", "Limited")]
[string]$Runlevel = "Limited",

[parameter(Mandatory = 0, Position = 16)]
[parameter(Mandatory = 0, Position = 17)]
[bool]$Force = $false
)

end
{
Write-Verbose ($VerboseMessages.CreateTask -f $taskName, $taskPath)
Write-Verbose ($VerboseMessages.CreateTask -f $TaskName, $TaskPath)
# exist
$existingTaskParam =
@{
TaskName = $taskName
TaskPath = $taskPath
TaskName = $TaskName
TaskPath = $TaskPath
}

$currentTask = GetExistingTaskScheduler @existingTaskParam
Expand Down Expand Up @@ -4657,14 +4660,15 @@ function Set-ValentiaScheduledTask
}

# validation
if ($execute -eq ""){ throw New-Object System.InvalidOperationException ($ErrorMessages.ExecuteBrank) }
if ($Execute -eq ""){ throw New-Object System.InvalidOperationException ($ErrorMessages.ExecuteBrank) }
if (TestExistingTaskSchedulerWithPath @existingTaskParam){ throw New-Object System.InvalidOperationException ($ErrorMessages.SameNameFolderFound -f $taskName) }

# Action
$actionParam =
@{
argument = $argument
execute = $execute
Argument = $Argument
Execute = $Execute
WorkingDirectory = $WorkingDirectory
}

# trigger
Expand All @@ -4691,8 +4695,8 @@ function Set-ValentiaScheduledTask
$scheduledTask = New-ScheduledTask -Description $Description -Action $action -Settings $settings -Trigger $trigger -Principal $principal
@{
InputObject = $scheduledTask
TaskName = $taskName
TaskPath = $taskPath
TaskName = $TaskName
TaskPath = $TaskPath
Force = $Force
}
}
Expand All @@ -4704,8 +4708,8 @@ function Set-ValentiaScheduledTask
Settings = $settings
Trigger = $trigger
Description = $Description
TaskName = $taskName
TaskPath = $taskPath
TaskName = $TaskName
TaskPath = $TaskPath
Runlevel = $Runlevel
Force = $Force
}
Expand Down Expand Up @@ -4783,17 +4787,22 @@ function Set-ValentiaScheduledTask
return $false
}

function CreateTaskSchedulerAction ($argument, $execute)
function CreateTaskSchedulerAction ($Argument, $Execute, $WorkingDirectory)
{
$action = if ($argument -ne "")
if (($Argument -eq "") -and ($WorkingDirectory -eq ""))
{
New-ScheduledTaskAction -Execute $execute -Argument $Argument
return New-ScheduledTaskAction -Execute $execute
}
else

if (($Argument -ne "") -and ($WorkingDirectory -eq ""))
{
return New-ScheduledTaskAction -Execute $Execute -Argument $Argument
}

if (($Argument -ne "") -and ($WorkingDirectory -ne ""))
{
New-ScheduledTaskAction -Execute $execute
return New-ScheduledTaskAction -Execute $Execute -Argument $Argument -WorkingDirectory $WorkingDirectory
}
return $action
}

function CreateTaskSchedulerTrigger ($ScheduledTimeSpan, $ScheduledDuration, $ScheduledAt, $Daily, $Once)
Expand Down
4 changes: 2 additions & 2 deletions valentia/valentia.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Generated by: guitarrapc
#
# Generated on: 12/1/2014
# Generated on: 2014/12/07
#

@{
Expand All @@ -15,7 +15,7 @@
ModuleVersion = '0.4.10'

# ID used to uniquely identify this module
GUID = 'ae25aed9-2739-4482-9eed-9fca77ea9d94'
GUID = 'b1adbe64-298e-49a6-930b-5a726225806d'

# Author of this module
Author = 'guitarrapc'
Expand Down

0 comments on commit d77b885

Please sign in to comment.