Hi @A.Elrayes ,
Move-AdObject
expect a GUID or DN as the -Identity
parameter.
Also you should provide the full DN of the -TargetPath
.
https://learn.microsoft.com/en-us/powershell/module/activedirectory/move-adobject?view=windowsserver2022-ps
In your script the variable $OriginalOU
contains the DN of the user, not the OU of the user. So could try this:
Move-ADobject -Identity $OriginalOU -Targetpath "OU=old users,OU=xxx,DC=xyz,DC=abc"
For Set-AdUser
you could try this:
Set-ADuser $ChangeDiscription -Description ("Disabled dueto inactivity - Moved from $OriginalOU")
If you are posting scripts please use the Code Sample
option (the Icon with 101010
). The Q&A editor will remove some characters of scripts if you paste the script as normal text.
----------
(If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)
Regards
Andreas Baumgarten