diff --git a/Public/Get/Get-HaloInvoice.ps1 b/Public/Get/Get-HaloInvoice.ps1 index 9a2b44c..57686af 100644 --- a/Public/Get/Get-HaloInvoice.ps1 +++ b/Public/Get/Get-HaloInvoice.ps1 @@ -84,7 +84,10 @@ function Get-HaloInvoice { [switch]$PostedOnly, # Filter for non-posted invoices only. [Parameter( ParameterSetName = 'Multi' )] - [switch]$NotPostedOnly + [switch]$NotPostedOnly, + # Filter by payment status. Provide an array of status ids. + [Parameter( ParameterSetName = 'Multi' )] + [object]$PaymentStatuses ) Invoke-HaloPreFlightCheck $CommandName = $MyInvocation.MyCommand.Name @@ -93,6 +96,14 @@ function Get-HaloInvoice { if ($InvoiceID) { $Parameters.Remove('InvoiceID') | Out-Null } + # Transform the payment statuses parameter to a HTML encoded string. + $PaymentStatuses = if ($PaymentStatuses -isnot [string]) { + if ($PaymentStatuses -is [int64[]]) { + return [System.Net.WebUtility]::UrlEncode($PaymentStatuses -join ',') + } else { + return [string]$PaymentStatuses + } + } try { if ($InvoiceID) { Write-Verbose "Running in single-invoice mode because '-InvoiceID' was provided."