Admin/Category/New-SDPCategory.ps1
Function New-SDPCategory { <# .SYNOPSIS Add new Category .PARAMETER InputData Input data as hashtable or JSON string .EXAMPLE $InputData = @{ category = @{ name = "Wsparcie obsługi komputera" description = "Test" } } $Category = New-SDPCategory -InputData $InputData .NOTES Author: Michal Gajda .LINK https://ui.servicedeskplus.com/APIDocs3/index.html#add-an-user https://help.servicedeskplus.com/user-ci-api #> [CmdletBinding( SupportsShouldProcess=$True, ConfirmImpact="Low" )] param ( [String]$UriSDP, [String]$ApiKey, [Parameter(Mandatory=$true)] $InputData ) Begin { #Create headers if(!$MyInvocation.BoundParameters.ContainsKey("UriSDP")) { $UriSDP = $Global:UriSDP } if(!$MyInvocation.BoundParameters.ContainsKey("ApiKey")) { $ApiKey = $Global:ApiKey } } Process { $InvokeParams = @{ UriSDP = $UriSDP ApiKey = $ApiKey Method = "POST" EntityUri = "/api/v3/categories" InputData = $InputData } #Send request If ($PSCmdlet.ShouldProcess($InputData.item.name,"Add new category")) { $Result = Invoke-SDPAPIEntity @InvokeParams $Results = $Result.category } #Return result if($MyInvocation.BoundParameters.ContainsKey("Debug")) { Return $Result } else { Return $Results } } End{} } |