Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

get-aduser syntax assistance

Posted on 2014-04-08
4
Medium Priority
?
521 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 668 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 668 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 664 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
How to deal with a specific error when using the Enable-RemoteMailbox cmdlet to create a mailbox in the cloud-based service, for an existing user in an on-premises Active Directory.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
Suggested Courses

688 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