Dear all,
I have a question about creating AD user and mailbox:
- Background:
There're 4 sites in my organization, and 2 DCs in each site. Exchange servers are in site A, the AD administrators work in sites B & C. I wrote a powershell script to help them creating AD users and mailboxes. Parts of the code are listed:
$DC = $env:LOGONSERVER -replace "\\" New-ADUser @newUser -OtherAttributes @{ pager = $EmployeeID } -Server $DC -ErrorAction Stop Enable-Mailbox -Identity $samAccountName -Alias $samAccountName -Database $msdb -DomainController $DC
- My question:
Sometimes the mailbox cannot be created, and I get the error: Cannot find an object with identity: 'Sandy.Lorena' under: 'DC=ms,DC=com'
I want to create an AD user, make some settings, and then create a mailbox for this AD user. How should I do if I want to prevent the above error?
Thank you in advance.