Simple Powershell Scripts pt.1

Powershell is well documented everywhere on the web, but I often find myself having to google simple things that I’ve done in the past. Instead, I’ll just put them in here for quick reference for myself!

Export all users in a specific OU to a .csv

$OUPath = 'OU=FTE,OU=<OU>,DC=<DC>,DC=com'
$ExportPath = 'C:\temp\users.csv'

Get-ADUser -Filter * -SearchBase $OUPath | Select-Object -Property Name, UserPrincipalName | Export-Csv $ExportPath

Leave a comment