Control 3.2: Data Retention Policies for Copilot Interactions — PowerShell Setup
Automation scripts for deploying and managing data retention policies governing Copilot interaction data and generated content.
Prerequisites
- Modules:
ExchangeOnlineManagement,Microsoft.Graph.Compliance - Permissions: Purview Compliance Admin
- PowerShell: Version 7.x recommended
Connect to Required Services
Scripts
Script 1: Create or Record Microsoft Copilot Experiences Retention Policy
Microsoft documents *-AppRetentionCompliance* cmdlets for newer retention locations, including Microsoft Copilot experiences. Verify the cmdlets and preview application values in the tenant before relying on automation. If the cmdlets or application values are unavailable, create the Microsoft Copilot experiences retention policies in the Purview portal and retain portal evidence with the records management schedule.
# Create a Microsoft Copilot experiences policy where AppRetention cmdlets are available.
$copilotApplications = "User:M365Copilot,CopilotForSecurity,CopilotinFabricPowerBI,CopilotStudio,CopilotinBusinessApplicationplatformsSales,SQLCopilot"
if (Get-Command New-AppRetentionCompliancePolicy -ErrorAction SilentlyContinue) {
New-AppRetentionCompliancePolicy `
-Name "FSI-Copilot-Experiences-Retention-3Year" `
-Applications $copilotApplications `
-Comment "Retains Microsoft Copilot experiences content per FSI policy" `
-Enabled $true
New-AppRetentionComplianceRule `
-Name "FSI-Copilot-Experiences-3yr" `
-Policy "FSI-Copilot-Experiences-Retention-3Year" `
-RetentionDuration 1095 `
-RetentionComplianceAction Keep
} else {
Write-Warning "AppRetention cmdlets unavailable. Create the policy in the Purview portal and retain portal evidence."
}
# Export evidence for Microsoft Copilot experiences policies by approved name.
$copilotExperiencePolicyNames = @(
"FSI-Copilot-Experiences-Retention-3Year",
"FSI-Copilot-Experiences-Retention-6Year"
)
foreach ($policyName in $copilotExperiencePolicyNames) {
if (Get-Command Get-AppRetentionCompliancePolicy -ErrorAction SilentlyContinue) {
Get-AppRetentionCompliancePolicy -Identity $policyName -ErrorAction SilentlyContinue |
Select-Object Name, Enabled, DistributionStatus
}
Get-RetentionCompliancePolicy -Identity $policyName -ErrorAction SilentlyContinue |
Select-Object Name, Enabled, DistributionStatus
}
Script 2: Create Content Retention Policies
# Create retention policy for Copilot-generated content across workloads
New-RetentionCompliancePolicy `
-Name "FSI-Copilot-Content-Retention" `
-Comment "Retains Copilot-generated content in SPO, ODB, and EXO per SEC Rule 17a-4" `
-SharePointLocation "All" `
-ExchangeLocation "All" `
-OneDriveLocation "All" `
-Enabled $true
New-RetentionComplianceRule `
-Name "FSI-Copilot-Content-6yr" `
-Policy "FSI-Copilot-Content-Retention" `
-RetentionDuration 2190 `
-RetentionComplianceAction Keep `
-RetentionDurationDisplayHint Years
Write-Host "Content retention policy created: 6-year retention" -ForegroundColor Green
# Create Teams retention policy to cover meeting recaps and chat summaries
New-RetentionCompliancePolicy `
-Name "FSI-Copilot-Teams-Retention" `
-Comment "Retains native Teams chat and channel messages; Copilot meeting recaps require Microsoft Copilot experiences policy" `
-TeamsChannelLocation "All" `
-TeamsChatLocation "All" `
-Enabled $true
New-RetentionComplianceRule `
-Name "FSI-Copilot-Teams-3yr" `
-Policy "FSI-Copilot-Teams-Retention" `
-RetentionDuration 1095 `
-RetentionComplianceAction Keep `
-RetentionDurationDisplayHint Years
Write-Host "Teams retention policy created: 3-year retention" -ForegroundColor Green
Script 3: Report on Existing Retention Policies
# Generate a report of all retention policies relevant to Copilot.
# Microsoft Copilot experiences policies are portal-managed; match them by approved names.
$policies = Get-RetentionCompliancePolicy | Where-Object {
$_.Name -like "*Copilot*" -or $_.Comment -like "*Copilot*"
}
foreach ($policy in $policies) {
$rules = Get-RetentionComplianceRule -Policy $policy.Name
[PSCustomObject]@{
PolicyName = $policy.Name
Enabled = $policy.Enabled
DistributionStatus = $policy.DistributionStatus
SharePointLocation = $policy.SharePointLocation
OneDriveLocation = $policy.OneDriveLocation
ExchangeLocation = $policy.ExchangeLocation
TeamsLocation = $policy.TeamsChannelLocation
ModernGroupLocation = $policy.ModernGroupLocation
RetentionDays = ($rules | Select-Object -First 1).RetentionDuration
Action = ($rules | Select-Object -First 1).RetentionComplianceAction
}
} | Format-Table -AutoSize
Script 4: Create Retention Label for Copilot Content
# Create and publish a retention label for Copilot-generated regulatory records
New-ComplianceTag `
-Name "FSI-Copilot-Regulatory-Record-6yr" `
-Comment "Retention label for Copilot-generated regulatory records in FSI environment" `
-RetentionAction Keep `
-RetentionDuration 2190 `
-RetentionType CreationAgeInDays `
-IsRecordLabel $true
# Publish the label policy to PowerShell-supported workload locations.
# Add Microsoft Copilot experiences through the Purview portal if the label must apply there.
New-RetentionCompliancePolicy `
-Name "Publish-Copilot-Retention-Labels" `
-RetentionComplianceTag "FSI-Copilot-Regulatory-Record-6yr" `
-SharePointLocation "All" `
-ExchangeLocation "All" `
-Enabled $true
Write-Host "Retention label created and published to PowerShell-supported workload locations" -ForegroundColor Green
Script 5: Verify Threaded Summary Retention Coverage
# Check that both Teams and Copilot experiences locations are covered by retention
$teamsPolicies = Get-RetentionCompliancePolicy | Where-Object {
$_.TeamsChannelLocation -ne $null -or $_.TeamsChatLocation -ne $null
}
$copilotExpPolicies = Get-RetentionCompliancePolicy | Where-Object {
$_.Name -like "*Copilot-Experiences*"
}
Write-Host "=== Threaded Summary Retention Coverage Check ===" -ForegroundColor Cyan
Write-Host "Teams retention policies (covers meeting content and embedded summaries): $($teamsPolicies.Count)" -ForegroundColor $(if ($teamsPolicies.Count -gt 0) { "Green" } else { "Red" })
Write-Host "Portal-managed Copilot experiences policies (matched by approved names): $($copilotExpPolicies.Count)" -ForegroundColor $(if ($copilotExpPolicies.Count -gt 0) { "Green" } else { "Red" })
if ($teamsPolicies.Count -eq 0) {
Write-Warning "No Teams retention policy found — threaded summaries in Teams may not be retained"
}
if ($copilotExpPolicies.Count -eq 0) {
Write-Warning "No Copilot experiences retention policy found by approved name — verify portal evidence for Copilot-generated summaries"
}
# FINRA Rule 4511(c) requires preservation in format compliant with applicable regulations
# Both locations must be covered for complete threaded summary retention
Script 6: Check Retention Policy Distribution Status
# Verify all Copilot retention policies have distributed successfully
$allPolicies = Get-RetentionCompliancePolicy | Where-Object {
$_.Name -like "*Copilot*"
}
$failedPolicies = $allPolicies | Where-Object { $_.DistributionStatus -ne "Success" }
if ($failedPolicies.Count -gt 0) {
Write-Warning "The following retention policies have not distributed successfully:"
$failedPolicies | Select-Object Name, DistributionStatus | Format-Table -AutoSize
} else {
Write-Host "All Copilot retention policies distributed successfully" -ForegroundColor Green
}
Scheduled Tasks
| Task | Frequency | Script |
|---|---|---|
| Retention policy audit | Monthly | Script 3 |
| Distribution status check | Weekly | Script 6 |
| Threaded summary coverage verification | Quarterly | Script 5 |
| Policy configuration review | Quarterly | Scripts 1-2 (verify) |
| Label application report | Monthly | Script 4 (verify) |
Next Steps
- See Verification & Testing to validate retention policies
- See Troubleshooting for retention policy issues
- Back to Control 3.2