16 Jun 2011 @ 4:55 PM 

I wrote a Powershell script today that moves a mailbox and then resets its AD permissions (To fix ActiveSync issues after moving from Exchange 2007 to Exchange 2010). Just thought i’d share it.

#© Daniel Stone, 2011 daenks at daenks dawt org
param([string]$Source, [string]$Destination)
if (!$Source) {
Write-Host “Please Specify a Source Store with the -Source parameter”
Exit -1
}
if (!$Destination) {
Write-Host “Please Specify a Destination Store with the -Destination parameter”
Exit -2
}

$i = 0
$ds = New-Object System.DirectoryServices.DirectorySearcher([ADSI]”LDAP://dc=quintanaminerals,dc=com”)
$Moves = Get-Mailbox -Database $Source
foreach ($mailbox in $Moves) {
$i = $i + 1
Write-Host $i
if ($i -eq 14)
{
Write-Host “15 Mailbox Limit Exceeded. Please allow the first 15 moves to complete before starting more.”
Exit -3
}
New-MoveRequest -Identity “$($mailbox.DisplayName)” -TargetDatabase $Destination
$ds.Filter = “(&(objectCategory=person)(objectClass=user)(cn=$($mailbox.DisplayName)))”
$DSResults = $ds.FindAll()
foreach ($item in $DSResults) {
$user = $item.GetDirectoryEntry()
Write-Host “Correcting Permissions for: $($user.sAMAccountName)”
$user.psbase.ObjectSecurity.SetAccessRuleProtection($false,$true)
$user.psbase.CommitChanges()
}
}
#© Daniel Stone, 2011 daenks at daenks dawt org

I realize there are some improvements that i could make, like a LOT more error checking. But this will do for me for now 🙂

Oh yea, and WordPress messed up the indentation, sorry 🙂

Posted By: Daenks
Last Edit: 16 Jun 2011 @ 04:58 PM

EmailPermalinkComments (0)
Tags
 27 Oct 2009 @ 8:19 AM 

Hey all, recently I was transferred to a new full-time client here in Houston, and I have some interesting adventures in the works! This company has offices in Houston, China, Singapore, and Brazil; and I am going to be assisting in the setup of the IT Infrastructure in the Singapore office within the next month or two. There will be many lessons and adventures to talk about soon, stay tuned!

-D

Posted By: Daenks
Last Edit: 27 Oct 2009 @ 08:19 AM

EmailPermalinkComments (0)
Tags

 Last 50 Posts
Change Theme...
  • Users » 727
  • Posts/Pages » 8
  • Comments » 0
Change Theme...
  • VoidVoid « Default
  • LifeLife
  • EarthEarth
  • WindWind
  • WaterWater
  • FireFire
  • LightLight

About



    No Child Pages.