Public/New-FsAgentGroup.ps1
Function New-FsAgentGroup { <# .SYNOPSIS Creates an agent group within FreshService .DESCRIPTION The New-FsAgentGroup function inputs a new agent group into the FreshService domain *REQUIRED PARAMS* - Name .EXAMPLE New-FsAgentGroup -Name 'IT Supers' -Description 'test description' . . . .PARAMETER .INPUTS .OUTPUTS .NOTES .LINK #> [CmdletBinding()] #Enable all the default paramters, including Param( [Parameter(Mandatory=$true, ValueFromPipeline=$true, Position=0)] [String]$Name, [Parameter(Mandatory=$false, Position=1)] [String]$Description, [Parameter(Mandatory=$false, Position=2)] [String]$UnassignedFor, [Parameter(Mandatory=$false, Position=3)] [Int]$BusinessHourID, [Parameter(Mandatory=$false, Position=4)] [Int]$EscalateTo, [Parameter(Mandatory=$false, Position=5)] [Array]$Members, [Parameter(Mandatory=$false, Position=6)] [Array]$Observers, [Parameter(Mandatory=$false, Position=7)] [Boolean]$Restricted, [Parameter(Mandatory=$false, Position=8)] [Array]$Leaders, [Parameter(Mandatory=$false, Position=9)] [Boolean]$ApprovalRequired, [Parameter(Mandatory=$false, Position=10)] [Boolean]$AutoTicketAssign ) Begin{ Write-Verbose -Message "Starting $($MyInvocation.InvocationName) with $($PsCmdlet.ParameterSetName) parameterset..." Write-Verbose -Message "Parameters are $($PSBoundParameters | Select-Object -Property *)" Connect-FreshServiceAPI } Process{ $Attributes = @{} if ($Name){ $Attributes.Add('name', $($Name)) } if ($Description){ $Attributes.Add('description', $($Description)) } if ($AgentIDs){ $Attributes.Add('agent_ids', $($AgentIDs)) } if ($UnassignedFor){ $Attributes.Add('unassigned_for', $($UnassignedFor)) } if ($BusinessHourID){ $Attributes.Add('business_hours_id', $($BusinessHourID)) } if ($EscalateTo){ $Attributes.Add('escalate_to', $($EscalateTo)) } if ($Members){ $Attributes.Add('members', $($Members)) } if ($Observers){ $Attributes.Add('observers', $($Observers)) } if ($Restricted){ $Attributes.Add('restricted', $($Restricted)) } if ($Leaders){ $Attributes.Add('leaders', $($Leaders)) } if ($ApprovalRequired){ $Attributes.Add('approval_required', $($ApprovalRequired)) } if ($AutoTicketAssign){ $Attributes.Add('auto_ticket_assign', $($AutoTicketAssign)) } $Body = $Attributes | ConvertTo-Json Get-FreshServiceAPIResult -APIEndpoint "$($APIURL)/groups" -Body $Body -Method 'POST' } End{ Write-Verbose -Message "Ending $($MyInvocation.InvocationName)..." } } |