0% found this document useful (0 votes)
134 views1 page

Active Directory User Export Script

The document contains a PowerShell script that queries Active Directory for user accounts within a specified OU, selects specific user properties, sorts by name, and exports the results to a CSV file.

Uploaded by

Abhijeet Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
134 views1 page

Active Directory User Export Script

The document contains a PowerShell script that queries Active Directory for user accounts within a specified OU, selects specific user properties, sorts by name, and exports the results to a CSV file.

Uploaded by

Abhijeet Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

Import-Module ActiveDirectory

Get-ADUser -Filter * -SearchBase


"OU=Netherlands,OU=EMEA,OU=Manpower,DC=CORP,DC=ROOT,DC=GLOBAL" -SearchScope 2
-Properties
lastlogondate,mail,enabled,description,accountexpirationdate,whenchanged,whencreate
d,manager,department,company -ErrorAction SilentlyContinue | select
samaccountname,name,mail,enabled,description,accountexpirationdate,whencreated,when
changed,lastlogondate,manager,department,company,distinguishedname | sort name |
export-csv "D:\NL-Report\Security-AllNLUsers_Date.csv" -NoTypeInformation

***********************************************************************************
********************************
Gomathi script:

Get-ADUser -Filter * -SearchBase


"OU=Netherlands,OU=EMEA,OU=Manpower,DC=CORP,DC=ROOT,DC=GLOBAL" -SearchScope 2
-Properties
samaccountname,lastlogondate,whencreated,whenchanged,accountexpirationdate,enabled,
displayname,givenName,surname,mail,userPrincipalName,description,employeeID,company
,title,mobile,department,manager,distinguishedname -ErrorAction SilentlyContinue |
select
samaccountname,lastlogondate,whencreated,whenchanged,accountexpirationdate,enabled,
displayname,givenName,surname,mail,userPrincipalName,description,employeeID,company
,title,mobile,department,manager,distinguishedname | sort name | export-csv
"C:\Temp\ou.csv" -NoTypeInformation

***********************************************************************************
********************************
Myscript

Get-ADUser -Filter * -SearchBase


"OU=Netherlands,OU=EMEA,OU=Manpower,DC=CORP,DC=ROOT,DC=GLOBAL" -SearchScope 2
-Properties
samaccountname,lastlogondate,whencreated,whenchanged,accountexpirationdate,enabled,
displayname,givenName,surname,mail,userPrincipalName,description,employeeID,company
,title,mobile,department,manager,distinguishedname -ErrorAction SilentlyContinue |
select
samaccountname,lastlogondate,whencreated,whenchanged,accountexpirationdate,enabled,
displayname,givenName,surname,mail,userPrincipalName,description,employeeID,company
,title,mobile,department,manager,distinguishedname | sort name | export-csv "D:\NL-
Report\Security-AllNLUsers_Date-2.csv" -NoTypeInformation

You might also like