title: Modify Active Directory Client OU from Client Machine
body: <p>I am trying to create a powershell startup script for my domain controlled computers that will place the computer into the the specified OU. I would like for the variables to be taken on the local computer and then passed to the remote server. Once there I would like to execute the last two lines on the server.  </p>
  
  <p>The script below does work if it is ran on the server however as stated above I would like to be able to execute this from a client machine. How can I make this happen?</p>
  
  <pre><code>$computername = $env:ComputerName
  $new_ou = "OU=TestOU,DC=Test,DC=Controller,DC=com"
  Import-Module ActiveDirectory
  Get-ADComputer $computername | Move-ADObject -TargetPath $new_ou
  </code></pre>
  
  <p>Note: Before anyone asks...my goal is to have the OU be determined by the client IP address. I understand that there are scripts that will do the discribed above but they run strictly on the server and query the DNS. I would rather have this run as a startup script on the local computer so I an better control which computers are being moved. At this point I am not interested in tackling this issue. Only the issue of how to execute the above lines on a local machine. </p>