I was wondering if it is possible to change the user OU (organizational unit) in ActiveDirectory using PowerShell. I have a script that should update many fields. I use the Set-ADUser command to update, but I cannot find a flag that will allow me to update OU. The following is the Set-ADUser command that I am currently using. Variables are set earlier in the script and should not be relevant to the issue.
set-ADUser -identity $samName -GivenName $firstName -Surname $lastName -Department $department -Description $description -Manager $manager -AccountExpirationDate $acctExp -Organization $org
I also have a script that creates users. This script allows me to install OU. It makes me believe that I can change IT after creation. The following is the command I use to create the user. Again, the variables are set earlier in the script.
New-ADUser -Name $dName -SamAccountName $sam -GivenName $firstName -Surname $lastName -Path $OU -AccountPassword $passwd -ChangePasswordAtLogon $true -Department $department -Description $description -Manager $manager -Organization $org
If there is a flag for the Set-ADUser command, that would be great, otherwise any help would be appreciated. Thanks.
source share