Forum Discussion

TherealKillerbe's avatar
TherealKillerbe
Brass Contributor
Apr 03, 2025

Purview -> Powershell

i need to export some users their data before their licenses are removed.

It is about 60 users, so i would rather user powershell instead of the purview portal to automate the job.

So i have been playing around with the commandlets, to get an idea to build the script.

The strange thing is what i see in Powershell is not represented in the Purview portal.

We had an older compliance case which was no longer used. I tried to remove the compliance case by the Purview portal, but nothing happens when clicking "delete case" or "close case".

i then reverted back to PowerShell by using the Remove-ComplianceCase "$CaseName", where the compliance case was successfully removed. When running the Get-ComplianceCase, i can see that the old compliance case is indeed removed, however the removed compliance case is still present in the Purview portal even several hours after deleting the case with PowerShell.

Then started to play around with a new compliance search

New-ComplianceSearch -Name "$($TargetMailbox.displayName) License Cleanup" -ExchangeLocation "$($TargetMailbox.PrimarySmtpAddress)" -Case "License Cleanup" -SharePointlocation "$($PNPPersonalSite.url)"

after refreshing a couple of times i could see the compliance search in the purview portal. Then started the compliance search by using the Start-ComplianceSeacrh commandlet and verified that the search status was completed:

Get-compliancesearch "$($TargetMailbox.displayName) License Cleanup" | select status

However in the Purview portal no statistics were shown (not available yet). Didn't spend to much attention as i already saw discrepancies between the purview portal and what i saw in Powershell, so continued exporting compliance search with a compliance search action to export the data in the process manager

New-ComplianceSearchAction -SearchName ""$($TargetMailbox.displayName)" -Export

 Can successfully retrieve the compliancesearch action in Powershell and can see that the status is completed, but fail to retrieve the export in the purview portal.

Get-ComplianceSearchAction -case "License CleanUp" -includecredential | fl

Did not achieve a way in downloading the export results via PowerShell, but would already be pretty pleased if i could achieve the first two steps via PowerShell. But as i am unable to retrieve the export in the Purview portal, i am afraid that i am still stuck.

I can create an export in the Purview portal from the compliance search i created in Powershell.

Can anyone please explain me the issue with the discrepancies between what i see in PowerShell and the Purview Portal and is it possible to see the exports created in powershell in the purview portal? And is it feasible to download the export from Powershell as well (Start-Process)?  

 

No RepliesBe the first to reply

Resources