Public/Migration/MailboxMove/PostMigrationTask/Set-MailboxMoveRetentionPolicy.ps1
function Set-MailboxMoveRetentionPolicy { <# .SYNOPSIS Sets Office 365 Retention Policy during a migration project Either CSV or Excel file from SharePoint can be used .DESCRIPTION Sets Office 365 Retention Policy during a migration project Either CSV or Excel file from SharePoint can be used .PARAMETER SharePointURL Sharepoint url ex. https://fabrikam.sharepoint.com/sites/Contoso .PARAMETER ExcelFile Excel file found in "Shared Documents" of SharePoint site specified in SharePointURL ex. "Batchex.xlsx" Minimum headers required are: BatchName, UserPrincipalName .PARAMETER MailboxCSV Path to csv of mailboxes. Minimum headers required are: BatchName, UserPrincipalName .PARAMETER Tenant This is the tenant domain - where you are migrating to. Example if tenant is contoso.mail.onmicrosoft.com use contoso .EXAMPLE Set-MailboxMoveRetentionPolicy -MailboxCSV c:\scripts\batches.csv .EXAMPLE Set-MailboxMoveRetentionPolicy -SharePointURL 'https://fabrikam.sharepoint.com/sites/Contoso' -ExcelFile 'Batches.xlsx' -Tenant Contoso .NOTES General notes #> [CmdletBinding(DefaultParameterSetName = 'SharePoint')] param ( [Parameter(Mandatory, ParameterSetName = 'SharePoint')] [ValidateNotNullOrEmpty()] [string] $SharePointURL, [Parameter(Mandatory, ParameterSetName = 'SharePoint')] [ValidateNotNullOrEmpty()] [string] $ExcelFile, [Parameter(Mandatory, ParameterSetName = 'SharePoint')] [ValidateNotNullOrEmpty()] [string] $Tenant, [Parameter(Mandatory, ParameterSetName = 'CSV')] [ValidateNotNullOrEmpty()] [string] $MailboxCSV ) end { if ($Tenant -notmatch '.mail.onmicrosoft.com') { $Tenant = '{0}.mail.onmicrosoft.com' -f $Tenant } switch ($PSCmdlet.ParameterSetName) { 'SharePoint' { $SharePointSplat = @{ SharePointURL = $SharePointURL ExcelFile = $ExcelFile Tenant = $Tenant } Invoke-SetMailboxMoveRetentionPolicy @SharePointSplat | Out-GridView -Title "Results of Set Mailbox Retention Policy" } 'CSV' { $CSVSplat = @{ MailboxCSV = $MailboxCSV } Invoke-SetMailboxMoveRetentionPolicy @CSVSplat | Out-GridView -Title "Results of Set Mailbox Retention Policy" } } } } |