I need a little help. I have little PowerShell experience, but I am working with the Pocket Guide on my side and with my GoogleFu.
Currently my plan is to request a username and save it, use Get-ADUser with the saved username to get and save DistinguishedName, use Move-ADObject to move the user from DistinguishedName to the target path.
The problem I am facing is storing and calling these things. I have this that gives me user information. How can I highlight only the distinguished name and save it?
$name = read-host "Enter user name" Get-ADUser $name
After saving the DN, can Move-ADObject use the stored value? I tried to save individual values, for example:
Move-ADobject 'CN=$name,OU=department,OU=company,DC=Domain,DC=net' -TargetPath 'OU=NonActive,OU=company,DC=Domain,DC=net'
But this returns "Directory object not found" because it does not use the stored value.
source share