#Bulk convert linked mbx to user mbx (e2k7) using strictly ps. #Written by Georg Hinterhofer #Updated by Tony Murray July 2010 #get a list of all linked mbx $linkedmbx = get-mailbox -resultsize unlimited | where {$_.linkedmasteraccount -match "MYDOMAIN"} #loop through all mbx foreach ($mbx in $linkedmbx) { #Grab ACL containing AEA property $AclContainingAEA = $mbx | Get-MailboxPermission | ? {$_.accessrights -like "*ExternalAccount*"} $ExAccount = $AclContainingAEA.User $LDAPPath = "LDAP://" + $mbx.DistinguishedName $object = [ADSI]"$LDAPPath" $objectsidh = $object.sIDHistory.value If (!$objectsidh) { write-host "sIDHistory is blank" } Else { write-host "sIDHistory is present" $objectsidh = $Object.getex(“sidhistory”) trap { #write-host "Error doing getex: $_" continue } foreach($sid in $objectSidh) { #Fix AEA in AD $sidh = new-object System.Security.Principal.SecurityIdentifier $sid,0 write-host "About to remove $sidh" Remove-MailboxPermission -Identity $mbx.DistinguishedName -User "$sidh" -AccessRights ExternalAccount -confirm:$false } } #Fix MsExchRecipientType in AD so that Box is displayed as User and no longer as linked (change from 2 to 1) $object.put("msExchRecipientTypeDetails",1) #Fix msExchMasterAccountSID (clear in AD) so that "isLinked" and "linkeMasterAccount" gets cleared. $object.putex(1,"msExchMasterAccountSid",$null) #Save information to AD $object.setinfo() }