Getting Campaign Reports .csv (Follow Up)

It’s possible. Here’s how I did it using the IdentityNow PowerShell Modules.
You need to get the ID’s of the in-scope campaigns, which I won’t go into here. But once you have them:

First generate the reports - one call for each report type:

Invoke-IdentityNowRequest -Method POST -URI "https://$($orgName).api.identitynow.com/beta/campaigns/$($_.id)/run-report/CAMPAIGN_COMPOSITION_REPORT" -Headers HeadersV3
Invoke-IdentityNowRequest -Method POST -URI "https://$($orgName).api.identitynow.com/beta/campaigns/$($_.id)/run-report/CAMPAIGN_REMEDIATION_STATUS_REPORT" -Headers HeadersV3
Invoke-IdentityNowRequest -Method POST -URI "https://$($orgName).api.identitynow.com/beta/campaigns/$($_.id)/run-report/CAMPAIGN_STATUS_REPORT" -Headers HeadersV3
Invoke-IdentityNowRequest -Method POST -URI "https://$($orgName).api.identitynow.com/beta/campaigns/$($_.id)/run-report/CERTIFICATION_SIGNOFF_REPORT" -Headers HeadersV3

I introduce a 10-20 second sleep here. That’s probably longer than necessary, but just to safe:

Start-Sleep -Seconds 20

Then loop through the campaigns, generate the file names you want to save the reports as and use something like either or both of the following:

$filePath = "./CampaignReports/$($campaignPathName)$($suffix) - $($_.name).pdf"
Invoke-IdentityNowRequest -Method GET -URI "https://$($orgName).api.identitynow.com/cc/api/report/get/$($_.id)?format=pdf" -Headers HeadersV3 -OutFile $filePath

OR

$filePath = "./CampaignReports/$($campaignPathName)$($suffix) - $($_.name).csv"
$result = Invoke-IdentityNowRequest -Method GET -URI "https://$($orgName).api.identitynow.com/cc/api/report/get/$($_.id)?format=csv" -Headers HeadersV3 
Set-Content -Path $filePath -Value $result
4 Likes