Here is your updated script:
----- start -----
$root=([ADSI]"").distinguishedName
$Group = [ADSI]("LDAP://CN=Domain Admins,CN=Users,"+ $root)
$members = $Group.member
foreach( $member in $members ) { $ary = $member.Split( "," ); $result =
$ary[0].Substring(3); $result; }
----- end -----
If you put it in zippy.ps1, then to output it to a file:
./zippy >c:\temp\filename.txt
Which is a shortcut for
./zippy | out-file -force -filepath c:\temp\filename.txt -encoding ascii
Regards,
Michael B. Smith
Consultant and Exchange MVP
http://TheEssentialExchange.com
-----Original Message-----
From: Joseph Heaton [mailto:[email protected]]
Sent: Tuesday, January 04, 2011 4:08 PM
To: NT System Admin Issues
Subject: Powershell question
I found this really simple powershell script that will list all members of a
specified AD group. What I'd like to do is then pipe that to a text file.
Here's the script:
$root=([ADSI]"").distinguishedName
$Group = [ADSI]("LDAP://CN=xxx, CN=Users,"+ $root)
$Group.member
Now, this gives a nice, simple list of users in group xxx, but it is the FQDN
of the user. What I'd really like to do is kick out a list of just the user
name, without the CN= stuff. Also, once that list is kicked out, I'd like to
pipe that list into a text file, so I can e-mail it to a requestor.
Anyone know how to do this easily? (Complete scripting noob here, btw)
Thanks,
Joe
~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~
---
To manage subscriptions click here:
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to [email protected]
with the body: unsubscribe ntsysadmin
~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~
---
To manage subscriptions click here:
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to [email protected]
with the body: unsubscribe ntsysadmin