# Specify the OUs $ous = @("OU=Users,OU=Hamburg,OU=Webservice,DC=Webservice,DC=intra", "OU=Users,OU=Madrid,OU=Webservice,DC=Webservice,DC=intra", "OU=Users,OU=Paris,OU=Webservice,DC=Webservice,DC=intra") # Create an empty array to hold the users $users = @() # Loop through each OU and get the users foreach ($ou in $ous) { $users += Get-ADUser -Filter * -SearchBase $ou -Properties GivenName, Surname | Where-Object { $_.Enabled -eq $true } | Select-Object GivenName, Surname } # Export the users to a CSV file $users | Export-Csv -Path ActiveUsers.csv -NoTypeInformation -Encoding UTF8