jblu

jblu / find_ad_users.ps1

Last active 6 months ago

Like 0
README.md Raw

Find AD Users

This script is used to export AD users from GSMIXAZ OU

It requires the OU to passed as a parameter to the script. Examples of these OUs:

  • supp02
  • ivan01
  • tstcls

Usage Example

Make sure you open powershell with your GSMIXAZ account. If you do not do this you will not have permission.

cd c:\Temp
.\Export-AD-Users.ps1 supp02

Output

This is exactly how you will run it on the arcus support server

PS C:\Temp> .\Export-AD-Users.ps1 supp02
Exporting users for [supp02]
Exported to .\11-07-2023_045457.csv
PS C:\Temp>
find_ad_users.ps1 Raw
1[CmdletBinding()]
2Param([parameter(Position=0)]$identifier)
3write-host "Exporting users for [$identifier]"
4$date = Get-Date -UFormat "%d-%m-%Y_%I%M%S"
5write-host "Exported to .\$identifier$date.csv"
6Get-ADUser -Filter * -Properties * -SearchBase "OU=$identifier,OU=Customers,DC=GSMIXAZ,DC=local" | `
7select displayname, userprincipalname, EmailAddress, Enabled | `
8export-csv -NoTypeInformation -path .\$identifier$date.csv