PoshCode Archive  Artifact [684b4905e8]

Artifact 684b4905e85786b50a510720be9735ead07babb3c15ccff98f18374b81a87c04:

  • File Move-Mailbox-2010.ps1 — part of check-in [936c28d3d8] at 2018-06-10 13:27:38 on branch trunk — this script is called from a scheduled task running under an account with the recipient role (user: chriskenis size: 1435)

# encoding: utf-8
# api: powershell
# title: Move-Mailbox 2010
# description: this script is called from a scheduled task running under an account with the recipient role
# version: 0.1
# author: chriskenis
# license: CC0
# x-poshcode-id: 3557
# x-archived: 2012-08-04T23:32:05
# x-published: 2012-08-02T08:49:00
#
# gets identities from a distribution group in AD, here named xc2010move but it can be anything you like
# this way anyone with permissions to add users to this group can initialize a migration
# with the right permissions endusers can even add themselves to this group
#
$DistGroup = XC2010Move
$MB2Move = Get-DistributionGroup XC2010Move | Get-DistributionGroupMember | Get-Mailbox | Where {($_.RecipientTypeDetails -eq "LegacyMailbox") -and ($_.MailboxMoveStatus -eq ‘None’)} | Get-Random -Count 20
$batch = "MoveMB_{0:ddMMM_yyyy}" -f (Get-Date)
ForEach ($SingleMailbox in $MB2Move) {New-MoveRequest –Identity $SingleMailbox -BadItemLimit 100 -AcceptLargeDataLoss -Batchname $batch}
$MB2RemoveFromDG = Get-DistributionGroup XC2010Move | Get-DistributionGroupMember | Get-Mailbox | Where {($_.RecipientTypeDetails -eq "UserMailbox") -and ($_.MailboxMoveStatus -eq ‘Completed’)}
ForEach ($member in $MB2RemoveFromDG){Remove-DistributionGroupMember -Identity XC2010Move -Member $member -Confirm:$False}
ForEach ($member in $MB2RemoveFromDG){Remove-MoveRequest -Identity $member -Confirm:$False}