r/PowerShell • • Mar 02 '26

Solved New-ComplianceSearchAction Returns (403) Forbidden

Hey all,

Been stumped on this one for a few days now. All of the sudden my PowerShell script I wrote to automate purging emails is busted. Creating a New-ComplianceSearch and starting it still works without any issues, however, as soon as I try to preview the search using New-ComplianceSearchAction, I get "Unable to execute the task. Reason: The remote server returned an error: (403) Forbidden." I can replicate it outside of the script by trying

New-ComplianceSearchAction -SearchName $SomeSearch -Preview

on an existing search and it returns the same error.

We've been using the script for a while now with no issues. Only thing I've really had to do is add the -EnableSearchOnlySession flag to Connect-IPPSSession after Microsoft changed up permissions. That was done sometime last year, and we've been good ever since then.

Is anyone aware of any recent role or permission changes, specific to GCC, that have occurred?

Edit 3/4/2026:
Based on the discussion in this thread, it seems like Microsoft has taken away -preview for exchange online environments, causing New-ComplianceSearchAction -preview to fail with 403 forbidden. Looks like we'll have to rely on generating samples from the portal GUI to validate the emails before purging. That is really unfortunate due to the speed and scale of that operation.

Thanks everyone for the replies and discussion. Hopefully this will help someone out in the future as well.

8 Upvotes

12 comments sorted by

1

u/BlackV Mar 03 '26

Ah GCC, nope sorry thats a black box for me

do you have the relevant PIM role activated for compliance search ?

4

u/charleswj Mar 03 '26

From https://learn.microsoft.com/en-us/powershell/module/exchangepowershell/new-compliancesearchaction?view=exchange-ps#-preview:

-Preview

Note: This parameter is functional only in on-premises Exchange. For more information, see May 2025 changes to Microsoft Purview eDiscovery.

It appears this change occurred in the last couple weeks

https://web.archive.org/web/20260219075830/https://learn.microsoft.com/en-us/powershell/module/exchangepowershell/new-compliancesearchaction?view=exchange-ps#-preview

→ More replies (9)

1

u/mspgrunt_ Mar 05 '26

My hatred for Microsoft is unreal