Skip to content

Deprovision a Compliance Recording Policy in Microsoft Teams using PowerShell

Note

This articles describes the steps required to remove a Compliance Recording Policy in Microsoft Teams using Powershell cmdlets.

There is an alternative (much easier) method of creating of a recording policy in Microsoft Teams, using MiaRec automation. Check Disconnect MiaRec from Microsoft Teams for details.

Ignore these instructions if you used MiaRec automation to delete a recording policy.

Prerequisites

Open PowerShell console as admnistrator

Press Win+R to open Run dialog and enter the following command to run PowerShell console:

powershell.exe Start-Process powershell -Verb runAs

Run PowerShell console

Install Microsoft Teams PowerShell Module

Install-Module MicrosoftTeams

Install-Module MicrosoftTeams

Note

If you see the error PowerShellGet requires NuGet provider version '2.8.5.201' or newer..., then run the following commands:

Install-Module PowershellGet -AllowClobber -Force

And try again to install module MicrosoftTeams.

Sign-in to Microsoft Teams (as tenant global admin)

In PowerShell console, run:

Connect-MicrosoftTeams

You will be asked to sign in to your Microsoft accounts. Make sure you sing-in with your Teams global administrator account.

Connect-MicrosoftTeams

After a successfull sign-in, you should see your Teams tenant ID in a console.

Connect-MicrosoftTeams Success

The section below provide instructions how to remove a Compliance Recording Policy in Microsoft Teams account.

Step 1. Define variables

# Replace MIAREC_APPLICATION_ID with the value provided by MiaRec
$RecorderAppID = "MIAREC_APPLICATION_ID"

# Define variables
$PolicyName = "MiaRecRecording"

# Get Recording Application ObjectId
$RecorderObjectId = Get-CsOnlineApplicationInstance `
    | Where-Object {$_.ApplicationId -Match "$RecorderAppID"} `
    | Select-Object -ExpandProperty ObjectId

Step 2. Unassign a recording policy from users

First, list all users that have been assigned any Compliance Recording Policy, run:

Get-CsOnlineUser `
    | Where-Object {$_.TeamsComplianceRecordingPolicy  -ne $Null} `
    | ft UserPrincipalName,TeamsComplianceRecordingPolicy

Alternatively, if you would like to narrow-down your search to a particular recording policy, run:

# Set your policy name below
$PolicyName = "MiaRecRecording"

Get-CsOnlineUser `
    | Where-Object {$_.TeamsComplianceRecordingPolicy  -eq $PolicyName} `
    | ft UserPrincipalName,TeamsComplianceRecordingPolicy

Next, for each user, run the following command to remove the policy assignment (replace USER_EMAIL_ADDRESS with actual user emails):

# Replace USER_EMAIL_ADDRESS with user's email
Grant-CsTeamsComplianceRecordingPolicy `
    -PolicyName $null `
    -Identity "USER_EMAIL_ADDRESS"

Step 3. Unassign a recording policy from groups

First, check what groups have the recording policy assignement:

Get-CsGroupPolicyAssignment -PolicyType TeamsComplianceRecordingPolicy

Next, for each group, run the following command to remove the policy assignment (replace GROUP_ID_HERE with the identificator of the group shown in the previous command output):

Remove-CsGroupPolicyAssignment `
    -PolicyType TeamsComplianceRecordingPolicy `
    -GroupId GROUP_ID_HERE

Step 4. Unassign a global recording policy

To unassign a global recording policy, you simply need to delete the Compliance Recording Policy (see the steps below).

Step 5. Delete a Compliance Recording Policy

First, list all the Compliance Recording Policies configured in your tenant:

Get-CsTeamsComplianceRecordingPolicy

The global recording policy, if enabled, will be show at the top in the output.

To delete a compliance recording policy, run:

# Set your policy name below
$PolicyName = "MiaRecRecording"

# Delete a policy
Remove-CsTeamsComplianceRecordingPolicy `
    -Identity $PolicyName `
    -Force

Note

This command only works, if no users are assigned to the policy. You will need to unassign policy from users prior to deletion of the policy.

Step 6. Delete the application instance

Microsoft does not provide a cmdlet for removing an online application instance. You can however find the application instance in Azure Active Directory and remove it from there. Application Instances are stored in the directory as a user account.

Login to Microsoft 365 admin center with you Microsoft admin credentials at admin.microsoft.com.

Navigate to Users > Active users and locate the MiaRec application user. Use a search box to quickly locate it by name. Select such a user and click Delete button.

MiaRec delete Microsoft Teams integration - delete application user