powershell adduser creates onmicrosoft account RRS feed

  • Question

  • Hello,

    I am trying to create a script that reads from csv, to create new users. But when I use it, instead of creating the email of the user on the local domain it puts the user under the onmicrosoft.microsoft.com domain.The path I use has the domain, but I can't seem to find what is the matter with it.

    The code I use for creating users is this:

    New-ADuser -Name "$fname $lname" -GivenName $fname -Surname $lname -UserPrincipalName "$fname.$lname" -AccountPassword $securePassword -Path "CN=Users,DC=MYDOMAIN,DC=COM" -City $city -Company $company -Department $department -Description $description -EmailAddress $email -Title $jobtitle -Office $office -MobilePhone $telephone -POBox $zipcode -Enabled $True        

    Thank you!

    Tuesday, September 17, 2019 1:44 PM