title: Trying to move AD user and disable the account running some PowerShell
body: <p>I'm trying to run some PowerShell to move users to different OU and disable the account.</p>
  
  <p>Here is my code</p>
  
  <pre><code>    $ADUsers = Import-Xlsx 'C:\User Creation\ADUsersRemoval.xlsx' | Foreach {
          $test = Get-ADUser -LdapFilter "samaccountname -eq '$("$Firstname.$Lastname")" |
                  Move-ADObject -TargetPath "OU=Users,OU=Graveyard,DC=domain,DC=dc" -PassThru |
                  Disable-ADAccount
      }
  }
  </code></pre>
  
  <p>The code runs without errors but doesn't do anything to the user account. What am I doing wrong?</p>
  
  <p><strong>Update</strong></p>
  
  <p>I realized I missed adding the values for <code>$Firstname</code> and <code>$Lastname</code>.</p>
  
  <p>Here is a code I tested with.</p>
  
  <pre><code>    $ADUsers = Import-Xlsx 'C:\User Creation\ADUsersRemoval.xlsx'
  
      foreach ($User in $ADUsers) {
          $Firstname = $User.Firstname
          $Lastname = $User.Lastname
  
          Get-ADUser -Filter "samaccountname -eq '$("$Firstname.$Lastname")'" -Properties 'mail'
      }
  }
  </code></pre>
  
  <p>Now works absolutely fine, gives me the details below. clearly reading from my xlsx file ps. Doing it with <code>'$("$Firstname.$Lastname")'"</code> works fine. Any other way then it won't read the xlsx file.</p>
  
  <pre>
  PSComputerName    : server
  RunspaceId        : ****************************************
  DistinguishedName : CN=user65 test65,CN=Users,DC=domain,DC=com
  Enabled           : True
  GivenName         : user65
  mail              : user65.test65@domain.com
  Name              : user65 test65
  ObjectClass       : user
  ObjectGUID        : afc3fc3b-c43a-4e1b-ad83-804ee605eb00
  SamAccountName    : user65.test65
  SID               :*************************************
  Surname           : test65
  UserPrincipalName : user65.test65@domain.com
  </pre>
  
  <p>but when trying to do the task of moving user and disabling. it doesn't action</p>
  
  <pre><code>$ADUsers = Import-Xlsx 'C:\User Creation\ADUsersRemoval.xlsx'
  
  foreach ($User in $ADUsers) {
      $Firstname = $User.Firstname
      $Lastname = $User.Lastname
  
      Get-ADUser -Filter "samaccountname -eq '$("$Firstname.$Lastname")'" |
          Move-ADObject -TargetPath "OU=Users,OU=Graveyard,DC=domain,DC=com" -PassThru |
          Disable-ADAccount
  }
  </code></pre>