Skip to content

Commit

Permalink
Add new ScheduledTask deployment type
Browse files Browse the repository at this point in the history
  • Loading branch information
DexterPOSH committed Nov 24, 2016
1 parent f7b9cab commit 7e4206a
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
4 changes: 4 additions & 0 deletions PSDeploy/PSDeploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ PSGalleryScript:
Script: PSGalleryScript.ps1
Description: EXPERIMENTAL... Deploys a PowerShell script to a repository like the PowerShell Gallery. WARNING- this modifies the scripts you want to deploy

ScheduledTask:
Script: ScheduledTask.ps1
Description: Deploys a ScheduledTask to a computer, using CIM/WMI.

Task:
Script: Task.ps1
Description: Support deployments by handling simple tasks.
Expand Down
67 changes: 67 additions & 0 deletions PSDeploy/PSDeployScripts/ScheduledTask.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<#
.SYNOPSIS
Uses ScheduledTasks PowerShell module to deploy scheduled tasks to Computers (available from Server 2012 onwards)
.DESCRIPTION
.PARAMETER Deployment
Deployment to run
.NOTES
#>
[CmdletBinding()]
param(
[ValidateScript({ $_.PSObject.TypeNames[0] -eq 'PSDeploy.Deployment' })]
[psobject[]]$Deployment,

# Specify the Computer name. Default localhost.
[String]$ComputerName = $env:ComputerName,

# Specify the credentials used to connect to the computer, used to open a CIMSession
[pscredential]$Credential,

# Mention the name of the task.
[String]$TaskName,

# Specify an array of task actions, max of 32.
[ValidateScript({$PSitem.Count -le 32})]
[String[]]$TaskAction,

# Specify the User id of the principal under whose context the scheduled task will run.
[Parameter(ParameterSetName='TaskPrincipal')]
[String]$RunAsUser,

# Specifies the level of user rights that Task Scheduler uses to run the tasks that are associated with the principal
[Parameter(ParameterSetName='TaskPrincipal')]
[ValidateSet('Highest','LUA')]
[String]$RunLevel,

# Specifies the security logon method that Task Scheduler uses to run the tasks that are associated with the principal
[Parameter(ParameterSetName='TaskPrincipal')]
[ValidateSet('None','Password','S4U','Interactive','Group','ServiceAccount','Interactive or Password')]
[String]$LogonType,

[Parameter(ParameterSetName='TaskTriggerOnce')]
[Switch]$Once,

[Parameter(ParameterSetName='TaskTriggerOnce')]
[Alias('StartTime')]
[DateTime]$At,

[Parameter(ParameterSetName='TaskTriggerOnce')]
[Switch]$RandomDelay


)

foreach($Deploy in $Deployment)
{
Do-SomethingWith $Deploy.DeploymentName
Do-SomethingElseWith $Deploy.Source
foreach($Target in $Deploy.Targets)
{
Deliver-SomethingTo $Target -From $Deploy.Source
}
}

0 comments on commit 7e4206a

Please sign in to comment.