title: How can I use PowerShell to move a user in AD?
body: <p>I'm in need of a little help. I've got little to no PowerShell experience but I'm working with a Pocket Guide by my side and my GoogleFu. </p>
  
  <p>Currently, my plan is to prompt for a username and store it, use Get-ADUser with the stored username to get and store the DistinguishedName, use Move-ADObject to move the user from the DistinguishedName to the target path.</p>
  
  <p>The problem I'm encountering is storing and calling these things. I have this, which gives me the info on a user. How can I isolate just the distinguished name and store it?</p>
  
  <pre><code>$name = read-host "Enter user name"
  Get-ADUser $name
  </code></pre>
  
  <p>After storing the DN, can Move-ADObject use the stored value? I've attempted to store individual values like:</p>
  
  <pre><code>Move-ADobject 'CN=$name,OU=department,OU=company,DC=Domain,DC=net' -TargetPath 'OU=NonActive,OU=company,DC=Domain,DC=net'
  </code></pre>
  
  <p>But this returns "Directory object not found" as it doesn't use the stored value.</p>