A little nifty Powershell script I threw together to move users around as they get promoted to allow them to have larger inbox quotas. =)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
Remove-Variable * -ErrorAction SilentlyContinue; Remove-Module *; $error.Clear(); Clear-Host Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 foreach($line in get-content "\\Server\Exports\Feed.txt") { if (![string]::IsNullOrWhiteSpace($line)) { $recipients = $line -split [RegEx]::Escape("|") Try { $EID = $recipients[1].trim() $EmpType = $recipients[17].trim() $User = Get-ADUser -LDAPFilter "(sAMAccountName=$EID)" -Properties Mail If ($User.mail -eq $Null) { continue } $Mb = Get-Mailbox -Identity $EID if (-not $Mb) { continue } if ($EmpType -eq "DIR") { if ($Mb.Database -ne "DB04" -and $Mb.Database -ne "DBA07") { Write-Host $EID $EmpType $Mb.Database New-MoveRequest -Identity $EID -TargetDatabase "DBA04" -WhatIf } } if ($EmpType -eq "ELT") { if ($Mb.Database -ne "DB07") { Write-Host $EID $EmpType $Mb.Database New-MoveRequest -Identity $EID -TargetDatabase "DBA07" -WhatIf } } } catch { } } } |