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. J
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.
~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~