Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Server > Scripting > Re: Group membership query fails because of special character

Reply
Thread Tools Display Modes

Re: Group membership query fails because of special character

 
 
Richard Mueller [MVP]
Guest
Posts: n/a

 
      03-17-2010


"JayCee" <> wrote in message
news:a4b85dc1-d71a-4011-8cf0-...
On Mar 16, 2:39 pm, Highlander <tron9...@msn.com> wrote:
> Hello All.
>
> Consider the following script:
> (watch for word wrap)
>
> strComputer = "atl-ws-01"
> strGroup = "Administrators"
> Set objGroup = GetObject("WinNT://" & strComputer & "/" & strGroup &
> ",group")
> For Each objUser in objGroup.Members
> Wscript.Echo objUser.Name
> Next
>
> This script works fine; except if there's a dollar sign ($) in the
> group name. Then I get the dreaded "(null): The group name could not
> be found."
>
> Using "GetObject WinNT", how can I query a (Windows server) local
> group which has a "$" in the group name?
>
> Any help would be greatly appreciated. Thanks!
>
> - Dave


I tested this out, thought I duplicated the problem, and then realize
I made a stupid mistake. So make sure you aren't making this same
mistake.

I created 2 new groups on on a Windows 7 box, added myself to them,
and then ran this script against Administrators, test$test, and
$tester groups. All were successful.

I deleted the 2 groups I created. Moved the script to a winxp box,
again created the 2 extra groups and added myself. Administrators
worked fine. Both the $ groups failed with a null error like you
said.

The actual problem was that I forgot to update strComputer when I
moved the script to the new box.

Once I updated strComputer to the new machine name, it successfully
parsed my username out of all the groups.
========

I tested on an XP machine and found no problems. I created a group with the
name "Test$", because computer sAMAccountNames always have a trailing "$"
character and I thought that might matter. Your code worked for me.

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Domian Local into Domain Admins Group Cosmo Active Directory 19 11-27-2009 12:09 PM
Special character as admin username - cannot find it from keyboard Mark Helmin Windows Vista Administration 3 09-17-2007 07:54 PM
Re: BITS/svchost fails, Windows Update not working Robert Aldwinckle Windows Vista Performance 7 07-23-2007 07:16 AM
Font Problem!! Nicholas Diamantides Windows Vista File Management 1 03-02-2007 06:46 AM
Help and support not working in Vista betterlead Windows Vista Installation 9 02-26-2007 12:08 AM



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 47 48 49 50 51 52 53 54 55 56 57 58 59