Along the same lines as Joe's script:

 

 

get-QADUser -SearchRoot 'DomainName.com/SomeOU' |format-table
name,memberof -wrap >h:\test1\output1.txt

 

 

 

 

Chris Bodnar, MCSE
Sr. Systems Engineer
Distributed Systems Service Delivery - Intel Services
Guardian Life Insurance Company of America
Email: [email protected]
Phone: 610-807-6459
Fax: 610-807-6003

  _____  

From: Joe Tinney [mailto:[email protected]] 
Sent: Friday, May 08, 2009 10:47 AM
To: NT System Admin Issues
Subject: RE: Dumping users and groups from AD into csv

 

In the interest of answering the question/request here is a rough script
that still needs tweaking:

 

## Script begins here

## Quest's PowerShell tools for AD are required for this to work. 

 

 

$output = "C:\list.csv" #Output filename

foreach ($user in get-qaduser) { #Gets a list of users to loop through

$displayname = $user.DisplayName; #Store their display name

foreach ($group in $user.MemberOf) { #Gets a list of user memberships

$groupname = $(get-qadgroup $group).Name; #Store the display name of the
group

$a = [char]34 #Creates a variable with a double-quote as the value to
format the output

"$a$DisplayName$a,$a$groupname$a" | Out-File -filePath $output -append
-noclobber; #Writes the output to file

}

}

 

## Script ends here

 

Outputs a comma separated, double-quote encapsulated (Just the way Excel
likes it) file to C:\list.csv. One line per group membership. You could
use PowerShell's array mechanisms to make it all one line per user if
desired.

 

After playing around with it some I definitely agree with Michael. There
must be a better way. :-)

 

From: Michael B. Smith [mailto:[email protected]] 
Sent: Friday, May 08, 2009 9:27 AM
To: NT System Admin Issues
Subject: RE: Dumping users and groups from AD into csv

 

why powershell?

 

adfind -default -f "(&(objectcategory=user)(objectclass=person))"
samaccountname memberof -csv -nodn

 

(and believe me, if I thought that PowerShell was the best tool for the
job, I would tell you.)

 

adfind is available at http://www.joeware.net <http://www.joeware.net/> 

 

  _____  

From: Stefan Jafs [[email protected]]
Sent: Friday, May 08, 2009 9:16 AM
To: NT System Admin Issues
Subject: Dumping users and groups from AD into csv

I have been doing some Googeling but drawing a blank.

 

I would like to have a PowerShell to dump all my users with group member
ships to a csv file any ideas?

 

Thanks

 

___________________________________

Stefan Jafs

 

This email and any attached files are confidential and intended solely for
the intended recipient(s). If you are not the named recipient you should
not read, distribute, copy or alter this email. Any views or opinions
expressed in this email are those of the author and do not represent those
of the Amico Corpoartion company. Warning: Although precautions have been
taken to make sure no viruses are present in this email, the company
cannot accept responsibility for any loss or damage that arise from the
use of this email or attachments.

 

 

 

 

 

 



-----------------------------------------
This message, and any attachments to it, may contain information
that is privileged, confidential, and exempt from disclosure under
applicable law.  If the reader of this message is not the intended
recipient, you are notified that any use, dissemination,
distribution, copying, or communication of this message is strictly
prohibited.  If you have received this message in error, please
notify the sender immediately by return e-mail and delete the
message and any attachments.  Thank you.
~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~

Reply via email to