public/Get-VSASDTicket.ps1
function Get-VSASDTicket { <# .Synopsis Returns an array of tickets or specified service desk or details on specified ticket. .DESCRIPTION Returns an array of tickets or specified service desk or details on specified ticket. Takes either persistent or non-persistent connection information. .PARAMETER VSAConnection Specifies existing non-persistent VSAConnection. .PARAMETER URISuffix Specifies URI suffix if it differs from the default. .PARAMETER ServiceDeskId Specifies id of service desk .PARAMETER Filter Specifies REST API Filter. .PARAMETER Paging Specifies REST API Paging. .PARAMETER Sort Specifies REST API Sorting. .EXAMPLE Get-VSASDTicket -ServiceDeskId 123456 .EXAMPLE Get-VSASDTicket -VSAConnection $connection -ServiceDeskId 123456 .INPUTS Accepts piped non-persistent VSAConnection .OUTPUTS Array of items that represent service desk tickets or ticket details #> [CmdletBinding()] param ( [parameter(Mandatory = $false, ValueFromPipelineByPropertyName = $true)] [VSAConnection] $VSAConnection, [parameter(DontShow, Mandatory=$false, ValueFromPipelineByPropertyName=$true)] [ValidateNotNullOrEmpty()] [string] $URISuffix = 'api/v1.0/automation/servicedesks/{0}/tickets', [Alias('ID')] [parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$true)] [ValidateScript({ if( $_ -notmatch "^\d+$" ) { throw "Non-numeric Id" } return $true })] [string] $ServiceDeskId, [parameter(Mandatory=$false, ValueFromPipelineByPropertyName=$true)] [ValidateScript({ if( $_ -notmatch "^\d+$" ) { throw "Non-numeric Id" } return $true })] [string] $ServiceDeskTicketId, [Parameter(Mandatory = $false)] [ValidateNotNullOrEmpty()] [string] $Filter, [Parameter(Mandatory = $false)] [ValidateNotNullOrEmpty()] [string] $Paging, [Parameter(Mandatory = $false)] [ValidateNotNullOrEmpty()] [string] $Sort ) if( -not [string]::IsNullOrWhiteSpace( $ServiceDeskTicketId) ) { $URISuffix = "api/v1.0/automation/servicedesktickets/$ServiceDeskTicketId" if ($ServiceDeskId) { Write-Error "ServiceDeskId can not be specified at same time with ServiceDeskTicketId"} } else { $URISuffix = $URISuffix -f $ServiceDeskId } [hashtable]$Params = @{ VSAConnection = $VSAConnection URISuffix = $URISuffix Filter = $Filter Paging = $Paging Sort = $Sort } #Remove empty keys foreach ( $key in $Params.Keys.Clone() ) { if ( -not $Params[$key]) { $Params.Remove($key) } } return Invoke-VSARestMethod @Params } Export-ModuleMember -Function Get-VSASDTicket |