/errors/purview/get-retentioncompliancepolicy-not-recognized
The term 'Get-RetentionCompliancePolicy' is not recognized as the name of a cmdlet
- 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:
Connect-IPPSSession -UserPrincipalName admin@contoso.com
Get-RetentionCompliancePolicyReproduce it
With the ExchangeOnlineManagement module (3.10.1) imported and no Security & Compliance connection:
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
| Cmdlets | Connect with |
|---|---|
| Get-Mailbox, Set-Mailbox, Get-MessageTraceV2, Search-UnifiedAuditLog | Connect-ExchangeOnline |
| *-RetentionCompliancePolicy, *-RetentionComplianceRule, *-ComplianceTag | Connect-IPPSSession |
| *-DlpCompliancePolicy, *-DlpComplianceRule, Get-DlpSensitiveInformationType | Connect-IPPSSession |
| Get-Label, Get-LabelPolicy | Connect-IPPSSession |
| *-ComplianceSearch, New-ComplianceSearchAction | Connect-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
- learn.microsoft.comlearn.microsoft.com/en-us/powershell/exchange/connect-to-scc-powershell
- learn.microsoft.comlearn.microsoft.com/en-us/powershell/module/exchangepowershell/get-retentioncompliancepolicy
- learn.microsoft.comlearn.microsoft.com/en-us/powershell/module/exchangepowershell/connect-ippssession