# This script requires the Quest Active Roles Directory Plugins # Download from: http://www.quest.com/powershell/activeroles-server.aspx # Version 1.0 # Author: Andy Grogan Write-Host "Configure Segregated Recipient Script - Version 1.0" Write-Host "" # Get Domain Controller $rootDSE = [adsi]"LDAP://RootDSE" $DC = $rootDSE.dnsHostName # Get the mailbox - Map the DN $strMbx = Read-Host "Enter in the samAccountName of the Mailbox" $strFilter = "(&(objectCategory=User)(samAccountName=$strMbx))" $objSearcher = New-Object System.DirectoryServices.DirectorySearcher $objSearcher.Filter = $strFilter $objPath = $objSearcher.FindOne() $objUser = $objPath.GetDirectoryEntry() $DN = $objUser.distinguishedName # Change the group membership $strDist = Read-Host "Please Enter in the name of the Group that you created for this users company" Get-Mailbox $strMBX | Add-DistributionGroupMember -Identity $strDist # Add in the Offline Address Book Settings $OAB = Read-Host "Please provide the Name of the OAB that you created for this users company" Set-Mailbox $strMBX -OfflineAddressBook $OAB # Change the msExchQueryBaseDN $strOU = Read-Host "Please Enter in the name of the Hosted Companies OU" $OUVAL = Get-QADObject $strOU | Select DN $user = ([ADSI]"LDAP://$DC/$DN").psbase $user.Properties["msExchQueryBaseDN"].Value = $OUVAL.dn $user.CommitChanges() # Modify the Filter Specific Attribute $strCA = Read-Host "Please Provide the Child Company Name (You would have configured this via the Segregation Tool)" Set-Mailbox $strMBX -CustomAttribute1 $strCA Write-Host "Configuration Completed"