Request/Task/New-SDPRequestTask.ps1
Function New-SDPRequestTask { <# .SYNOPSIS Add new Task to Request .PARAMETER RequestId Request id .PARAMETER InputData Input data as hashtable or JSON string .EXAMPLE $InputData = @{ "task" = @{ "title" = "New task" "description" = "Task description!" "status" = @{ "id" = "1" } } } $Task = New-SDPRequestTask -RequestId 25602 -InputData $InputData .NOTES Author: Michal Gajda .LINK https://www.manageengine.com/products/service-desk/sdpod-v3-api/requests/request_task.html#add-request-task #> [CmdletBinding( SupportsShouldProcess=$True, ConfirmImpact="Low" )] Param ( [String]$UriSDP, [String]$ApiKey, [Parameter(Mandatory=$true, ValueFromPipeline)] [Int]$RequestId, [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/requests/$RequestId/tasks" InputData = $InputData } #Send request If ($PSCmdlet.ShouldProcess($RequestId,"Add task to request id")) { $Result = Invoke-SDPAPIEntity @InvokeParams $Results = $Result.task } #Return result if($MyInvocation.BoundParameters.ContainsKey("Debug")) { Return $Result } else { Return $Results } } End{} } |