Public/Instances/New-ABInstance.ps1
function New-ABInstance { param ( [Parameter(Mandatory = $true)] $TemplateId, $Queue, $UserAccount, [hashtable] $Variables, [string] $Arguments, [datetime] $DeferUntil, $AuditFields, $IgnoreTriggers, $IgnoreAlerts, $IgnoreCalendar, $IgnoreExclusionList, $IsTestRun ) begin { } process { $Path = Get-ABPath -Path "TriggerInstance" [System.UriBuilder]$Uri = "$($_ABSession.Uri)$Path" $HttpQSCollection = [System.Web.HttpUtility]::ParseQueryString([String]::Empty) if ($TemplateId) { $HttpQSCollection.Add('templateId', $TemplateId) } $uri.Query = $HttpQSCollection.ToString() if ($Variables) { $VariableCollection = [System.Collections.ArrayList]::new() foreach ($VariableKey in $Variables.Keys) { [void]$VariableCollection.Add([PSCustomObject]@{ name = $VariableKey value = $Variables.$VariableKey }) } } Write-Verbose $Uri.Uri.OriginalString $Body = @{} if ($Variables) { $Body.variables = $VariableCollection } if ($Arguments) { $Body.arguments = $Arguments } if ($UserAccount) { $Body.userAccount = $UserAccount } if ($DeferUntil) { $Body.deferUntil = $DeferUntil } if ($Q0ueue) { $Body.queue = $Queue } if ($AuditFields) { $Body.auditFields = $AuditFields } $Body.ignoreTriggers = $IgnoreTriggers -eq $true $Body.ignoreAlerts = $IgnoreAlerts -eq $true $Body.ignoreCalendar = $IgnoreCalendar -eq $true $Body.ignoreExclusionList = $IgnoreExclusionList -eq $true $Body.isTestRun = $isTestRun -eq $true Invoke-ABRestMethod -method post -uri $Uri.Uri.OriginalString -body $Body } end { } } |