bin/Invoke-NewConsole.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
37
<#
.DESCRIPTION
    This Script will Execute a specified task, and submit any needed subtasks.
.PARAMETER PropertyFilePath
    A Rest PropertyFilePath is required.
.PARAMETER FunctionName
    A Rest PropertyFilePath is required.
.EXAMPLE
    Start-Process -WindowStyle Normal powershell.exe -ArgumentList "-file Invoke-NewConsole.ps1", "-PropertyFilePath $PropertyFilePath"
.NOTES
    This will execute a task against a specific target defined in the PembrokePS database.
#>

param(
    [Parameter(Mandatory=$true)][string]$PropertyFilePath,
    [Parameter(Mandatory=$true)][ValidateSet("Invoke-Wman", "Invoke-WmanKicker")]
    [string]$FunctionName
)
# Import required Modules
Get-Module -ListAvailable PembrokePS* | Import-Module
try 
{
    switch ($FunctionName)
    {
        Invoke-WmanKicker {
            Invoke-WmanKicker -PropertyFilePath $PropertyFilePath
        }
        Invoke-Wman {
            Invoke-Wman -PropertyFilePath $PropertyFilePath
        }
    } 
}
catch
{
    $ErrorMessage = $_.Exception.Message
    $FailedItem = $_.Exception.ItemName        
    Throw "Invoke-NewConsole: $ErrorMessage $FailedItem"
}