Change Retention Policy – Office 365

Change Retention Policy – Office 365

I wrote this powershell script to remove the Retention Policy that delete all emails in Users Deleted Items folder that are older then 30 days

Retention_Policy.ps1

$Cred = Get-Credential

Read-Host 'Press Enter to continue to Connect to Office 365' | Out-Null
Write-Host "Continueing..."
$s = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell -Credential $cred -Authentication Basic –AllowRedirection

Import-PSSession $s

Read-Host 'Press Enter to continue to Remove 30 days Deleted Items rule' | Out-Null
Write-Host "Continueing..."
Enable-OrganizationCustomization

Set-RetentionPolicyTag "Deleted Items" -RetentionEnabled $false

Read-Host 'Press Enter to exit script, All Done' | Out-Null