Skip to content

/errors/purview/get-retentioncompliancepolicy-not-recognized

The term 'Get-RetentionCompliancePolicy' is not recognized as the name of a cmdlet

verified onenvironmentlocal · windows 10.0.26200 arm64 · GNU bash 5.3.15 (Git Bash)updated
tool
Microsoft Purview (Security & Compliance PowerShell)
exit code
1
versions
ExchangeOnlineManagement 3.x
os
windows, linux, macos

Get-RetentionCompliancePolicy : The term 'Get-RetentionCompliancePolicy' is not recognized as the name of a cmdlet, function, script file, or operable program. means the session has no Security & Compliance PowerShell connection. Retention, DLP, sensitivity label and eDiscovery cmdlets are not part of Exchange Online PowerShell; they are created by Connect-IPPSSession:

powershell
Connect-IPPSSession -UserPrincipalName admin@contoso.com
Get-RetentionCompliancePolicy

Reproduce it

With the ExchangeOnlineManagement module (3.10.1) imported and no Security & Compliance connection:

powershell
Import-Module ExchangeOnlineManagement
try {
  Get-RetentionCompliancePolicy -ErrorAction Stop
} catch {
  $_.Exception.Message
  $_.FullyQualifiedErrorId
}

Output

The term 'Get-RetentionCompliancePolicy' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
CommandNotFoundException

The same happens for Get-DlpCompliancePolicy, New-RetentionComplianceRule, Get-Label, Get-ComplianceTag and the other Purview cmdlets.

Which connection for which cmdlet

CmdletsConnect with
Get-Mailbox, Set-Mailbox, Get-MessageTraceV2, Search-UnifiedAuditLogConnect-ExchangeOnline
*-RetentionCompliancePolicy, *-RetentionComplianceRule, *-ComplianceTagConnect-IPPSSession
*-DlpCompliancePolicy, *-DlpComplianceRule, Get-DlpSensitiveInformationTypeConnect-IPPSSession
Get-Label, Get-LabelPolicyConnect-IPPSSession
*-ComplianceSearch, New-ComplianceSearchActionConnect-IPPSSession -EnableSearchOnlySession

Connected, still not recognized

If Connect-IPPSSession succeeded, the cmdlet was not imported because of permissions: Security & Compliance PowerShell imports only the cmdlets your Purview roles allow. Check your role groups in the Microsoft Purview portal (Settings > Roles and scopes), get a role that includes retention management, then disconnect and connect again.

Sources