Forum Discussion

mrityunjay6492's avatar
mrityunjay6492
Copper Contributor
Jul 24, 2025
Solved

Accessing Content explorer data via SPN

Hi all, I am trying to get all the data from Content explorer for SITs matched files using https://learn.microsoft.com/en-us/powershell/module/exchange/export-contentexplorerdata?view=exchange-ps. I can run the command(Export-ContentExplorerData) when using User-Principle login but having issues while running it on SPN. 

 

For SPN Permissions, we followed the steps here https://learn.microsoft.com/en-us/powershell/exchange/app-only-auth-powershell-v2?view=exchange-ps
assigned all the permissions on the page but still having issues when running the script. 

 

One of the permission for SPN that seems mandatory is Content Explorer Content viewer. Now in purview portal, we are not able to assign this permissions to SPN as it throws an errror "Adding SPN to purview role groups is not supported"

 

Can we run this command(Export-ContentExplorerData) based on SPN(using application permission)? if yes what are the permission we need to assign to that SPN.

Thanks in advance

  • IIRC application permissions are not supported for the cmdlet, but you assign role groups to a service principal via PowerShell:

    Add-RoleGroupMember -Identity "ContentExplorerContentViewer" -Member xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

    Make sure to provision the SP first via New-ServicePrincipal. But again, afaik even if you grant the permissions, it is not currently supported.

3 Replies

  • IIRC application permissions are not supported for the cmdlet, but you assign role groups to a service principal via PowerShell:

    Add-RoleGroupMember -Identity "ContentExplorerContentViewer" -Member xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

    Make sure to provision the SP first via New-ServicePrincipal. But again, afaik even if you grant the permissions, it is not currently supported.

    • mrityunjay6492's avatar
      mrityunjay6492
      Copper Contributor

      Although I was not able to add  "Content Explorer List Viewer" role group to the SPN But I was able to add "Information Protection Investigators"  which included similar role as of "Content Explorer List Viewer". With the latest version 3.8 of ExchangeOnlineManagement this functinalty seems to be working.

      Added SPN to Microsoft Purview via this CMD
      New-ServicePrincipal -AppId $<VariableName1>.AppId -ObjectId $<VariableName1>.Id -DisplayName "<Descriptive Name>"

  • Hello 

    Make sure you followed all the steps to set up certificate-based authentication as below, 

    App-only authentication in Exchange Online PowerShell and Security & Compliance PowerShell | Microsoft Learn 

    If this is configured properly, then the permissions required is Content Explorer List Viewer role, as per the below article

    https://learn.microsoft.com/en-us/powershell/module/exchange/export-contentexplorerdata?view=exchange-ps#description 

    Hope this helps!

    Regards,

    PI

    Please mark as solution, if you find the answer helpful. This will assist others in the community who encounter a similar issue, enabling them to quickly find the solution and benefit from the guidance provided.

Resources