powershell script to create AD user

Sri56
Tera Contributor

Hi Guys,

I have used the following powershell command to create AD user:

New-ADUser -Name "XXX" -GivenName xxx -Surname xxx -SamAccountName XXXXXXX -UserPrincipalName xxxx@example.com -path "OU=XYZ, DC=example, DC=com"

But when running this script i am getting followinf error message:

"errorMessages": "The term 'New-ADUser' is not recognized as the name of a cmdlet, function, script file, or operable program.

So can someone please suggest on this.

Thanks,

Sri

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Sri,

Is the active directory package enabled on the mid server which you are using to run powershell.

Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi Ankur,

Thansks now i am not getting this error message.But it could not create user in AD even after successfully running this command.

 

Can you please help on this?

Thanks,

Sri

Hi Sri,

So what is the error message you are getting?

Regards

Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi Ankur 

I am not getting any error message.

Script status is successful but the user what i am trying to create is not happening in our AD.

Thanks,

Sri