jblu

jblu / find_ad_users.ps1

Last active 6 months ago

Like 0

jblu revised this gist 2 years ago · ae4b53b

2 files changed, 30 insertions

README.md (file created)
@@ -0,0 +1,22 @@
1 + # Find AD Users
2 +
3 + #### This script is used to export AD users from GSMIXAZ OU
4 + > It requires the OU to passed as a parameter to the script. Examples of these OUs:
5 + - supp02
6 + - ivan01
7 + - tstcls
8 +
9 + ## Usage Example
10 +
11 + > Make sure you open powershell with your GSMIXAZ account. If you do not do this you will not have permission.
12 +
13 + cd c:\Temp
14 + .\Export-AD-Users.ps1 supp02
15 +
16 + ## Output
17 + > This is exactly how you will run it on the arcus support server
18 +
19 + PS C:\Temp> .\Export-AD-Users.ps1 supp02
20 + Exporting users for [supp02]
21 + Exported to .\11-07-2023_045457.csv
22 + PS C:\Temp>
find_ad_users.ps1 (file created)
@@ -0,0 +1,8 @@
1 + [CmdletBinding()]
2 + Param([parameter(Position=0)]$identifier)
3 + write-host "Exporting users for [$identifier]"
4 + $date = Get-Date -UFormat "%d-%m-%Y_%I%M%S"
5 + write-host "Exported to .\$identifier$date.csv"
6 + Get-ADUser -Filter * -Properties * -SearchBase "OU=$identifier,OU=Customers,DC=GSMIXAZ,DC=local" | `
7 + select displayname, userprincipalname, EmailAddress, Enabled | `
8 + export-csv -NoTypeInformation -path .\$identifier$date.csv