If I have to create in active directory a new user using New-ADUser code ,example below, everything works fine.
New-ADUser -Name "User Test" -GivenName User -Surname Test -SamAccountName usertest -UserPrincipalName usertest@test .it -path "OU=Users, DC=test, DC=it"
When instead I have to create a new users by copying the profile of another user I am receiving the error " Access is denied".
New-ADUser : Access is denied
At line:2 char:1
- New-ADUser -Name "User test " -GivenName User " ...
As I am able to create a new user I should have the permission to run also the script to create a new user by copying the profile of an existing one....
$newuserattributes = Get-ADUser -Identity 111111 -Properties StreetAddress,City,Title,PostalCode,Office,Department,Manager
New-ADUser -Name "User test " -GivenName User -Surname test -SamAccountName usertest -UserPrincipalName usertest@domain.it -Instance $newuserattributes -AccountPassword (ConvertTo-SecureString Pas$W0rd!!12 -AsPlainText -Force) -ChangePasswordAtLogon $true -Enabled $false -EmployeeID 101010
Why am I receiving this error then?