get-aduser syntax assistance

Does anyone know how to use the get-aduser to list all ad users and all attributes associated with those users, and output the results into csv?

I am not to fussed about an alternative I would like to stick with powershell and this cmdlet.

I'd also be very interested if there is a get-adgroup equiv that can list all ad groups and their members?
Who is Participating?

Improve company productivity with a Business Account.Sign Up

Raheman M. AbdulConnect With a Mentor Senior Infrastructure Support Analyst & Systems DeveloperCommented:
Try this:

Get-ADUser -Filter * -Properties * | Select-Object -Property Name,SamAccountName,Description,EmailAddress,LastLogonDate,Manager,Title,Department,whenCreated,Enabled,Organization | Sort-Object -Property Name | Export-Csv -path C:\temp\ADusers.csv

Get-ADUser -Filter * -Properties * | Sort-Object -Property Name | Export-Csv -path C:\temp\ADusers.csv

For details:

You can also get help on this cmdlet using:

get-help get-aduser -detailed
get-help get-aduser -examples
pma111Author Commented:
Does the second of the 2 list all user attributes?

And assistance on a cmdlet for listing all groups in AD and their members, again exported to CSV?
AishConnect With a Mentor IT ManagerCommented:
To get group members you can use:

Get-ADGroupMember [-Identity] <ADGroup> [-AuthType {<Negotiate> | <Basic>}] [-Credential <PSCredential>] [-Partition <string>] [-Recursive <switch>] [-Server <string>] [<CommonParameters>]

You can also check
Justin YeungConnect With a Mentor Senior Systems EngineerCommented:
for get-aduser to get all attributes
Import-Module ActiveDirectory
$OutPath = "C:\ADUsers.csv"
Get-AdUser -Filter * -Properties * | Select-Object * | Export-Csv $Outpath

Open in new window

for get-adgroups and all adgroup members to a spreadsheet
function Get-GroupHierarchy ($searchGroup)
$groupMember = get-adgroupmember $searchGroup | sort-object objectClass -descending
   foreach ($member in $groupMember)
if ($member.objectclass -eq "user")
$userinfo = get-aduser $member.samaccountname -Properties *
if ($member.objectclass -eq "group")
$groupinfo = get-adgroup $member}
$array = @()
$Properties = @{"Group Name"=$;Name=$member.Name;SamAccountName=$member.samaccountname;"Canonical Name"=$Userinfo.canonicalname}
$Newobject = New-Object  PSObject -Property  $Properties
$Array +=$Newobject

$outpath = "C:\ADgroups.csv"

$Array | Select-Object "Group Name",Name,SamAccountName,"Canonical Name" | export-csv $outpath -Append

    if ($member.ObjectClass -eq "group")
        {Get-GroupHierarchy $}}

$ADGroups = Get-AdGroup -Filter * -Properties *
foreach ($AdGroup in $AdGroups)
Get-GroupHierarchy $Adgroup.Name

Open in new window

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.