Forum Discussion

alexrabbi's avatar
alexrabbi
Brass Contributor
Dec 22, 2022
Solved

powershell query

Hi All ,

 

I am using below command to get a list of all active users in AD, what should i add to this command to get UPN and Object ID ?

 

Get-ADUser -Filter {Enabled -eq $true} -properties * | select-object samaccountname,givenname,surname,Enabled | export-csv -path c:\temp\Enabledexportusers.csv

 

Thanks in Advance

Alex

  • List all the properties you want included in the CSV as part of the select-object cmdlet:

    Select-Object UserPrincipalName,ObjectId,samaccountname,givenname,surname,Enabled

2 Replies

  • List all the properties you want included in the CSV as part of the select-object cmdlet:

    Select-Object UserPrincipalName,ObjectId,samaccountname,givenname,surname,Enabled

Resources