title: Filter for just User objects in specific OU
body: <p>I am writing a powershell script to rename users within a specific target OU.</p>
  
  <p>The script runs fine, however I have noticed that the script also attempts to rename anything contained within child OUs as well. This is not the behaviour I am after but I am not sure how I change the filter to be specific to this requirement.</p>
  
  <p>This is the top part of the script.</p>
  
  <pre><code>Import-Module ActiveDirectory
  
  # Change the following Target OU to match your target
  $ou = "ou=Testing,ou=My Users,dc=my,dc=domain"
  
  # Set up Log files
  $users = $null
  New-Item -ItemType Directory -Force -Path C:\Logs
  
  $Logfile = "C:\Logs\$($ou).log"
  Out-File -FilePath $Logfile -Force -encoding ASCII
  
  Function LogWrite
  {
    Param ([string]$logstring)
    Add-content $Logfile -value $logstring
    Write-Host $logstring
  }
  
  # Start processing
  
  $users = Get-ADUser -SearchBase $ou -Filter * -Properties *
  ForEach($user in $users) 
  ......
  </code></pre>
  
  <p>I believe the <code>-Filter</code> parameter needs something more but I am not sure what, I assume I need to specify the objects as users only. Any help?</p>