Enable All Mailboxes in a Specified OU

Enables all the mailboxes in the organizational unit named OU.

 
 
 
 
 
(0)
Add to favorites
Exchange
8/10/2009
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question


  • Request for guidance
    1 Posts | Last post September 18, 2015
    • I would like to find if firstname and last name exist in org, in case yes, it should use middle name in SMTP policy and in case no, then use simple SMTP policy :
      
      Import-Module ActiveDirectory -ErrorAction Stop
      Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
      #Create Mailbox
      
      $OU = "OU=Sync,OU=Users,OU=Corp,DC=domain,DC=com"
      $sam = Get-aduser -filter * -Properties * | select CN
      $FirstName = Get-aduser -filter * -Properties * | select GivenName
      $LastName = Get-user -filter * -Properties *| select SN
      $Middle = Get-Aduser -filter * -Properties * | select Initials
      $EmailAddWithMiddle = ($FirstName+"."+$Middle+"."+$LastName+"@domain.com")
      $EmailAddWithoutMiddle = ($FirstName+"."+$LastName+"@domain.com")
      If ($Middle -eq "")
      {
      Get-User -ResultSize "Unlimited" -OrganizationalUnit $OU | Where-Object {$_.RecipientType -eq "User"} | Enable-Mailbox -Database DB2 | Set-Mailbox -EmailAddressPolicyEnabled $true
      }
      Else
      {
      Get-User -ResultSize "Unlimited" -OrganizationalUnit $OU | Where-Object {$_.RecipientType -eq "User"} | Enable-Mailbox -PrimarySmtpAddress $EmailAddWithMiddle -Database DB2
      }