Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Get group membership

Reply
 
Old 08-27-2008   #1 (permalink)
David Arro


 
 

Get group membership

Hello,

I am using the following code to obtain group membership:

$group = [ADSI] "LDAP://cn=group,ou=OU,dc=domain,dc=org"
$group.member

This works fine. I now want to write this to html so use

$group.member | convertto-HTML

But this simply displays numbers and not the group members...

I also get numbers if I use export-csv.

Does anybody know of a way to get group membership and output it to html or
csv?

Thanks


My System SpecsSystem Spec
Old 08-27-2008   #2 (permalink)


Vista Ultimate 32bit
 
 

Re: Get group membership

I know we solved this in the ScriptingAnswers.com forums but for readers who don't frequent that site here's what I posted:

The problem is that the output of Member is simply a string. The number is the length of the string. What you need to do is get each account, some properties and then convert to html or whatever. Here's an example:


$group.member | foreach {$user=[adsi]"LDAP://$_"; $user | Select @{name="DN";Expression={$_.DistinguishedName}}
,@{name="name";Expression={$_.Name}},@{name="Title";Expression={$_.Title}}} | convertto-html
My System SpecsSystem Spec
Old 08-31-2008   #3 (permalink)
Shay Levy [MVP]


 
 

Re: Get group membership

Hello David,

Adding to Jeffrey, use select-object to 'convert' the piped strings to custom
objects using a calculated property and then
assign the 'new' property name to ConvertTo-Html:


PS > $group.member | select @{n="DN";e={$_}} | ConvertTo-Html -Property DN



---
Shay Levy
Windows PowerShell MVP
http://blogs.microsoft.co.il/blogs/ScriptFanatic

DA> Hello,
DA>
DA> I am using the following code to obtain group membership:
DA>
DA> $group = [ADSI] "LDAP://cn=group,ou=OU,dc=domain,dc=org"
DA> $group.member
DA>
DA> This works fine. I now want to write this to html so use
DA>
DA> $group.member | convertto-HTML
DA>
DA> But this simply displays numbers and not the group members...
DA>
DA> I also get numbers if I use export-csv.
DA>
DA> Does anybody know of a way to get group membership and output it to
DA> html or csv?
DA>
DA> Thanks
DA>


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Check group membership across domains PowerShell
check group membership PowerShell
Get Group Membership for a User PowerShell
Group Membership Vista mail
ADSI and group membership - what am I doing wrong PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46