bin/Invoke-ExecuteTask.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<#
.DESCRIPTION
    This Script will Execute a specified task, and submit any needed subtasks.
.PARAMETER PropertyFilePath
    A Rest PropertyFilePath is required.
.PARAMETER TaskId
    A TaskId is required.
.PARAMETER RestServer
    A RestServer is required.
.PARAMETER TableName
    A TableName is required.
.EXAMPLE
    Start-Process -WindowStyle Normal powershell.exe -ArgumentList "-file Invoke-ExecuteTask.ps1", "-PropertyFilePath $PropertyFilePath -RestServer $RestServer -TableName $TableName -TaskId $TaskId"
.NOTES
    This will execute a task against a specific target defined in the PembrokePS database.
#>

param(
    [Parameter(Mandatory=$true)][string]$PropertyFilePath,
    [String]$TableName="tasks",
    [Parameter(Mandatory=$true)][Int]$TaskId,
    [Parameter(Mandatory=$true)][string]$RestServer
)
# Import required Modules
Import-Module -Name PembrokePSrest,PembrokePSutilities,PembrokePSwman,PowerLumber,RestPS -Force
try 
{
    $Host.UI.RawUI.WindowTitle = "Workflow_Wrapper TaskId:$ID"
    # Execute the Task
    Invoke-WorkflowWrapper -PropertyFilePath $PropertyFilePath -TableName $TableName -TaskId $TaskId -RestServer $RestServer
}
catch
{
    $ErrorMessage = $_.Exception.Message
    $FailedItem = $_.Exception.ItemName        
    Throw "Invoke-ExecuteTask: $ErrorMessage $FailedItem"
}