Link to home
Start Free TrialLog in
Avatar of Silvion
Silvion

asked on

Powershell - Create User Mailboxes and Apply a Address Book Policy and remove Email Alias.

Hi all,

Please excuse my ignorance, i'm haven't done a lot with powershell.

I have a roughly 300 user accounts in AD and need to create their mailboxes in exchange.  

I would like to create a mailboxes for each user in the OU, assign X address book policy and remove their secondary @internal email alias on their account. This is what i have come up with, am i on the right track?
Import-module activedirectory 
 
$users = Get-ADUser -LDAPfilter '(name=*)' -searchBase {DC=Staff,DC=Users,DC=DOMAIN,DC=INTERNAL.DOMAIN.TAS.EDU.AU}  
 
foreach($user in $users)  
{  
Enable-Mailbox -Identity $user.SamAccountName -Database <DBName>  
Update-EmailAddressPolicy -Identity "Staff Only Policy"  
}

Open in new window


TIA,
Patrick.
ASKER CERTIFIED SOLUTION
Avatar of Elango Sathyadev
Elango Sathyadev
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Silvion
Silvion

ASKER

Hi Elgano,

There was one part i had to chance but i forgot what it was now. But thank you for your help - That was fantastic. Appreciate it.