Solved

get-aduser syntax assistance

Posted on 2014-04-08
4
516 Views
Last Modified: 2014-04-29
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?
0
Comment
Question by:pma111
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 19

Accepted Solution

by:
Raheman M. Abdul earned 167 total points
ID: 39985921
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

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

For details: http://technet.microsoft.com/en-us/library/ee617241.aspx

You can also get help on this cmdlet using:

get-help get-aduser -detailed
or
get-help get-aduser -examples
0
 
LVL 3

Author Comment

by:pma111
ID: 39985935
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?
0
 
LVL 2

Assisted Solution

by:Aish
Aish earned 167 total points
ID: 39985946
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 http://pipe2text.com/?page_id=1218
0
 
LVL 14

Assisted Solution

by:Justin Yeung
Justin Yeung earned 166 total points
ID: 39985954
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"=$groupinfo.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 $member.name}}
} 

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

Open in new window

0

Featured Post

10 Questions to Ask when Buying Backup Software

Choosing the right backup solution for your organization can be a daunting task. To make the selection process easier, ask solution providers these 10 key questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article demonstrates probably the easiest way to configure domain-wide tier isolation within Active Directory. If you do not know tier isolation read https://technet.microsoft.com/en-us/windows-server-docs/security/securing-privileged-access/s…
There are times when we need to generate a report on the inbox rules, where users have set up forwarding externally in their mailbox. In this article, I will be sharing a script I wrote to generate the report in CSV format.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.
Suggested Courses

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question