I use this in my own Five9 PowerShell modules and find it helpful for watching a running report by ID and then fetching the results without me needing to consistently check in on it. Providing here if you'd like to add it into your module. Assign it as a variable and pass it the Five9ID and it'll do the rest. Optionally, you can specify the wait time to recheck the report or it will default to 5s retry intervals.. Sorry for the updates, I've not posted comments much to GitHub before so I couldn't get the CODE snippet identifier right.
# Watch report status (While/Until Running=False)
function Get-Five9ReportResults {
param(
# Five9 Report Id
[string]$Five9ReportID,
# Seconds to retry report status, defaults to 5 if not specified
[int]$WaitSeconds = 5
)
$ReportIsRunning = $true
While ($ReportIsRunning -eq $true) {
If($Five9AdminWS.isReportRunning($Five9ReportID,"") -eq $false ) {break :ReportDone}
Write-Host 'Report is still running...'
Start-Sleep -Seconds $WaitSeconds
}
:ReportDone do {
Write-Host 'Report finished, retrieving results'
# Get results and convert from CSV
$Five9AdminWS.getReportResultCsv($Five9ReportID) | ConvertFrom-Csv
# Report done, break loop
$ReportIsRunning = $false
}
Until ($ReportIsRunning -eq $false)
}
I use this in my own Five9 PowerShell modules and find it helpful for watching a running report by ID and then fetching the results without me needing to consistently check in on it. Providing here if you'd like to add it into your module. Assign it as a variable and pass it the Five9ID and it'll do the rest. Optionally, you can specify the wait time to recheck the report or it will default to 5s retry intervals.. Sorry for the updates, I've not posted comments much to GitHub before so I couldn't get the CODE snippet identifier right.