![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | output group membership on a single line I've been trying to figure out how to do this and I just can't seem to figure it out. What I have is this: (get-group -Identity <groupName>).members | select name This returns each name on a separate line: User1 User2 User3 User4 What I'd like is to change it to a series of strings that I can save to a file where it looks like this: User1,User2,User3,User4 Any thoughts on how to do this? As always thanks for any answers or feedback. |
My System Specs![]() |
| | #2 (permalink) | ||||||||||||||||||||||||
| Guest | Re: output group membership on a single line Perfect..thanks! Shay Levi wrote:
| ||||||||||||||||||||||||
My System Specs![]() | |||||||||||||||||||||||||
| | #3 (permalink) | ||||||||||||
| Guest | Re: output group membership on a single line Hi Steven, First strip the object to have the names (group members) as strings only, use foreach instead of select, and assign it to a variable. Here's an example using get-process: PS 22> $names = gps m* | foreach {$_.name} PS 23> $names Maxthon mDNSResponder msdtc msnmsgr mstsc In PowerShell v1.0 you can join the strings with [string]::join static method: PS 24> [string]::join(",",$names) Maxthon,mDNSResponder,msdtc,msnmsgr,mstsc PowerShell CTP(2) has a new -join parameter, so you can do: PS 25> $p -join "," Maxthon,mDNSResponder,msdtc,msnmsgr,mstsc --- Shay Levi $cript Fanatic http://scriptolog.blogspot.com
| ||||||||||||
My System Specs![]() | |||||||||||||
| | #4 (permalink) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Guest | Re: output group membership on a single line Hi Steven, Here is a nice one-liner for you. :-) (get-qadgroup -Identity <groupName>) | get-qadgroupmember | % {$names = @()} {$names += $_.name} {[string]::join(",",$names)} | out-file c:\temp\members.txt -aleksandar http://powershellers.blogpost.com On May 22, 8:37*pm, Steven <evetsl...@xxxxxx> wrote:
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
My System Specs![]() | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | #5 (permalink) | ||||||||||||
| Guest | RE: output group membership on a single line What about this? [PS] C:\>[string] ((get-group -Identity Legal).members | ForEach-Object {$_.name}) Kim Akers Brian Cox -- Tibor "Steven" wrote:
| ||||||||||||
My System Specs![]() | |||||||||||||
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Get group membership | David Arro | PowerShell | 2 | 08-31-2008 10:47 AM |
| Get Group Membership for a User | LE2 Strat | PowerShell | 4 | 01-31-2008 08:16 AM |
| Group Membership | Don D | Vista mail | 0 | 09-15-2007 09:31 AM |
| ADSI and group membership - what am I doing wrong | Neil Chambers | PowerShell | 5 | 07-14-2007 04:36 AM |
| Enumerating group membership & ADSI | CrazyKiwi | PowerShell | 7 | 07-05-2007 07:42 PM |