Solved

Power Shell - Quest - How to pull all the group membership for multiple users

Posted on 2013-06-12
5
444 Views
Last Modified: 2013-06-12
Hi EE

Any easy way to put a list of sAMAccountNames into a text file and have it output all the group memberships for each account into a .CSV file ?
0
Comment
Question by:MilesLogan
[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
  • 3
  • 2
5 Comments
 
LVL 40

Expert Comment

by:Subsun
ID: 39242080
Try this...
GC C:\user.txt | Get-QADUser | %{
	New-Object PSObject -Property @{
	Firstname = $_.Firstname
	Lastname = $_.Lastname
	DisplayName = $_.DisplayName
	Email = $_.Email
	Title = $_.Title
	group = ""
	}
$_.memberof | %{
	New-Object PSObject -Property @{
	Firstname = ""
	Lastname = ""
	DisplayName = ""
	Email = ""
	Title = ""
	group = ($_ -Split ",")[0] -replace "CN="
	}
 }
} | Select Firstname,Lastname,DisplayName,Email,Title,group | Export-Csv C:\report.csv -NoTypeInformation

Open in new window


Ref : http://www.experts-exchange.com/Programming/Languages/Scripting/Powershell/Q_28085213.html
0
 
LVL 2

Author Comment

by:MilesLogan
ID: 39242330
Hi SubSun

It works perfect ! I tried to modify it so it also pulls the account description but it did not work .. can you give me a hit ?

I added the two lines below but it did not output it .


description = $_.description
Description = ""
0
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
ID: 39242350
I guess you didn't select the description property..
Change last line to..
} | Select Firstname,Lastname,DisplayName,Email,Title,description,group | Export-Csv C:\report.csv -NoTypeInformation

Open in new window

0
 
LVL 2

Author Closing Comment

by:MilesLogan
ID: 39242431
Awesome as always !

Thank you so much again !
0
 
LVL 40

Expert Comment

by:Subsun
ID: 39242445
You are welcome, I'm glad I was able to help... :-)
0

Featured Post

Free NetCrunch network monitor licenses!

Only on Experts-Exchange: Sign-up for a free-trial and we'll send you your permanent license!

Here is what you get: 30 Nodes | Unlimited Sensors | No Time Restrictions | Absolutely FREE!

Act now. This offer ends July 14, 2017.

Question has a verified solution.

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

A company’s centralized system that manages user data, security, and distributed resources is often a focus of criminal attention. Active Directory (AD) is no exception. In truth, it’s even more likely to be targeted due to the number of companies …
Recently, Microsoft released a best-practice guide for securing Active Directory. It's a whopping 300+ pages long. Those of us tasked with securing our company’s databases and systems would, ideally, have time to devote to learning the ins and outs…
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.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

717 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