Public/Reports/Get-Five9ReportResult.ps1
function Get-Five9ReportResult { <# .SYNOPSIS Function returns the data from a report generated by Start-Five9Report .EXAMPLE $id = Start-Five9Report -FolderName 'Call Log Reports' -ReportName 'Call Log' $result = Get-Five9ReportResult -Identifier $id # Starts the Call Log report and using the returned identifier, gets the data from the report using Get-Five9ReportResult #> [CmdletBinding(PositionalBinding=$true)] param ( # Unique identifier returned by Start-Five9Report [Parameter(Mandatory=$true)][string]$Identifier, # Seconds to retry report retrieval, defaults to 5 if not specified [Parameter(Mandatory=$false)][int]$WaitSeconds = 5 ) try { Test-Five9Connection -ErrorAction: Stop $reportIsRunning = $true while ($reportIsRunning -eq $true) { $reportStatus = $null $reportStatus = $DefaultFive9AdminClient.isReportRunning($Identifier, "") if ($reportStatus -eq $false) { $reportIsRunning = $false } else { Write-Verbose "$($MyInvocation.MyCommand.Name): Report is still running. Waiting $WaitSeconds seconds..." Start-Sleep -Seconds $WaitSeconds } } $data = $global:DefaultFive9AdminClient.getReportResultCsv($Identifier) $objects = $data | ConvertFrom-Csv -ErrorAction: SilentlyContinue if ($objects.Count -gt 0) { Write-Verbose "$($MyInvocation.MyCommand.Name): Returning report with $($objects.Count) rows." return $objects } else { Write-Verbose "$($MyInvocation.MyCommand.Name): Report did not return any data." return $objects } } catch { $_ | Write-PSFive9AdminError $_ | Write-Error } } |