PowerShell - Get-ADUser
- Jon Boyette
- Oct 12, 2022
- 1 min read
Get ADUser, OU, Name, Username, and direct Manager, save as whatever name.ps1 suits you, make this 2 lines below, first stops at "second" DistinguishedName call, then the next 4 lines are 1 line.
$ou=Get-ADOrganizationalUnit -Filter * | Select-Object -Property DistinguishedName| Out-GridView -PassThru -Title "Choose the OU where Users Reside" | Select-Object -ExpandProperty DistinguishedName
get-aduser -filter * -searchbase $ou -properties manager |select DistinguishedName,name,samaccountname,@{Name = "Manager";Expression = {%{(Get-AdUser $_.Manager -Properties DisplayName).DisplayName}}}|export-csv c:\temp\ADUser_OU_Name_UserName_Manger.csv -nti
Comments