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]@{ Key = $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 $Body.ignoreAlerts = $IgnoreAlerts $Body.ignoreCalendar = $IgnoreCalendar $Body.ignoreExclusionList = $IgnoreExclusionList $Body.isTestRun = $isTestRun Invoke-ABRestMethod -method post -uri $Uri.Uri.OriginalString -body $Body } end { } } |