New-ADUser : Access is Denied

Hi, I’m trying to create a new-aduser ( a test user) through powershell to add in active directory. I am already running powershell as an admin, but I am getting “access is denied” error when I write this command. Is there anything wrong with my command? Could anyone help?

Hi, welcome to the forum :wave:

Running as administrator elevates your account on that machine. It doesn’t give you rights in AD.

If you have an account in Active Directory that has permissions to create accounts, you can use the -Credential parameter to ‘log in’ as that user:

New-ADUser -Name 'John Johnnson' - DisplayName 'John Johnson' -Description 'Tester' -Credential (Get-Credential)

You can find further information in the help file:

As a tip for future posts, when sharing code on the forum, please use the </> button, and copy and paste your code into your post rather than posting a screenshot. It makes it easier for everyone to copy and paste it for testing on their own systems.