My goal is to copy an existing user, including OU placement in the AD tree.
So far i have this:
$SName = Read-Host "Please Enter the login initials of the source user " $U = Get-ADUser -Identity $SName -Properties streetaddress,homepage,POBox,postalcode,city,country,company,department,office,fax $FirstName = read-host -Prompt "Enter first name of new user: " $LastName = read-host -Prompt "Enter last name of new user: " $DisplayName = "$Firstname $LastName" $DName = Read-Host "Please Enter logon initials of the new user " $UPN = $DName+"@scangl.com" $TempPassword = read-host -AsSecureString -Prompt "Enter temporary password (min. 8 characters)" $Path = Get-User -Identity $SName|Select "OrganizationalUnit" New-ADUser -Instance $u -Name $DisplayName -SamAccountName $DName -Path $Path -UserPrincipalName $UPN -DisplayName $DisplayName -givenname $FirstName -surname $LastName -AccountPassword $TempPassword -ChangePasswordAtLogon $True
As you may notice, i am trying to use the Get-User selecting the OrganizationalUnit, but it gives me the error: No superior reference has been configured for the directory service. The directory service is therefore unable to issue referrals to objects outside this forest.
Any suggestions how to copy the OU placement, or could it be that it is simply not possible to copy this user property?