Canberra, ACT, Australia
To be provided
Use Contact to message

Get AD Users and Export to CSV

Harmik Batth Tech's Blog

Get AD Users and Export to CSV

Powershell is not only making doing system administration tasks easy but also very effective and saves lot of time.

Instead of connecting to AD, searching for particular user and copying pasting contents. You can just use one line powershell script to do this for you.

Get-ADUser -Filter ‘*’ |  select SamAccountName, Department, Location | Export-Csv c:\temp\ADUsers.csv

Full script here

# Import Active Directory Module 
importmodule activedirectory
write-Output “Error while importing Active Directly module”

write-Output “please install AD Powershell modules first before running this script.”
# Get AD Users and export results to CSV 
$Users = GetADUser -Filter ‘*’ | select SamAccountName, Department, Location
$users  | Export-Csv c:\temp\ADUsers.csv


No Comments

Add your comment