I would like to create a new user on exchange, but I can't. The user uses their external address. Here is what I did and the following error message.
$password = "DsDggfde4563!"
$Name = "IAM, Test"
New-MailUser -Name $Name -MicrosoftOnlineServicesID "[email protected]" -ExternalEmailAddress "[email protected]" -Password (ConvertTo-SecureString $Password -AsPlainText -Force) -OrganizationalUnit "OU=Users,DC=test,DC=com"
Write-ErrorMessage : |Microsoft.Exchange.Configuration.Tasks.ThrowTerminatingErrorException|Organizational unit "test.com/Users" was not found. Please make sure you have typed it correctly.
CodePudding user response:
If you are trying the default users container then I think you are using the wrong -OrganizationalUnit. The default Users is a CN.
check the below code:
$password = "DsDggfde4563!"
$Name = "IAM, Test"
New-MailUser -Name $Name -MicrosoftOnlineServicesID "[email protected]" -ExternalEmailAddress "[email protected]" -Password (ConvertTo-SecureString $Password -AsPlainText -Force) -OrganizationalUnit "CN=Users,DC=test,DC=com"