Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


User Account Wildcards?

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,43221
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> User Account Wildcards?
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 User Account Wildcards? - 2/15/2007 1:23:24 AM   
  zym1ne

 

Posts: 5
Score: 0
Joined: 3/21/2006
Status: offline
Hoping someone out there can help as it seems I'm using wrong search terms on google...!

Still very new to scripting and a little confused as to whether or not it's possible to use wildcards in searching for Local Machine User Accounts?

Basically I'm trying to get a script to find a specific account or 2 then move them to the Local Admin group for the machine.

It's for a number of computers though and on each one the account/s will be named slightly different each time:

computer 1 = AccPC1, AccPC1b

computer 2 = AccPC2

computer 3 = AccPC3, AccPC3b

I'm hoping to have this script on each individual machine and to run it once only.

So far all I've been able to produce is the code below, which needs to have an account "explicitly" named :o(

Any help would be great here!


CODE:

set objComputer = CreateObject("Shell.LocalMachine")

strComputer = objComputer.MachineName

Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators")
Set objUser = GetObject("WinNT://" & strComputer & "/AccPC1")

objGroup.Add(objUser.ADsPath)
 
 
Post #: 1
 
 RE: User Account Wildcards? - 2/15/2007 4:27:42 AM   
  dm_4ever


Posts: 2359
Score: 36
Joined: 6/29/2006
From: Orange County, California
Status: offline
I don't believe you can use a wild card for local accounts using the WinNT provider, at least not that I've seen.  Perhaps you could enumerate through all the groups, get the members, use the InStr function to see if it is an account similar to the one you're looking for, add it to an array or dictionary, then loop through this collection with the names you need and add it to the admin group.

something like this:

      

//EDIT: Removed <span> tags

< Message edited by dm_4ever -- 5/24/2007 4:28:09 AM >


_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to zym1ne)
 
 
Post #: 2
 
 RE: User Account Wildcards? - 2/15/2007 5:40:00 AM   
  zym1ne

 

Posts: 5
Score: 0
Joined: 3/21/2006
Status: offline
Hi dm_4ever,

Thanks for the code and explanation...I've been working with it now since you posted it up but cant seem to grasp the inclusion of my code with it...???

I admit to not being to aware of the differing variables you've used but...

I used my earlier code but to no avail...if I expressley name the accounts (i.e "/AccPC1") then it's added pretty much as before...but if I try and use the captured variable from the array I cant seem to grasp the concept...

if i change my code to:

set objGroup = GetObject("WinNT://" & strComputer & "/Administrators")
set objUserAdd = GetObject("WinNT://" & strComputer & strUsrName)

it returns a variable not defined error?

The problem I have here i guess is understanding how to take a name found in the search and stored in the array and passing it to the:

objGroup.Add(objUserAdd.ADsPath)

????

(in reply to dm_4ever)
 
 
Post #: 3
 
 RE: User Account Wildcards? - 2/15/2007 6:03:20 AM   
  dm_4ever


Posts: 2359
Score: 36
Joined: 6/29/2006
From: Orange County, California
Status: offline
set objUserAdd = GetObject("WinNT://" & strComputer & "/" & strUsrName)

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to zym1ne)
 
 
Post #: 4
 
 RE: User Account Wildcards? - 2/15/2007 6:29:09 AM   
  zym1ne

 

Posts: 5
Score: 0
Joined: 3/21/2006
Status: offline
you're a star dm

thanks for getting back to me again on this one...!!!

I've used the code you suggested and now I'm getting an error:

"The Group name could not be found"

Code: 800708AC

No idea what this relates to...after googling all I've found is

Unable to locate the domain for the credentials provided. Try a different set of credentials.

anyone any ideas as to why this happens?


      

Thats the code in full as it stands.

But no idea as to why I get the error?

< Message edited by zym1ne -- 2/15/2007 6:30:14 AM >

(in reply to dm_4ever)
 
 
Post #: 5
 
 RE: User Account Wildcards? - 2/15/2007 6:47:57 AM   
  dm_4ever


Posts: 2359
Score: 36
Joined: 6/29/2006
From: Orange County, California
Status: offline
Try this.


      

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to zym1ne)
 
 
Post #: 6
 
 RE: User Account Wildcards? - 2/15/2007 7:00:37 AM   
  zym1ne

 

Posts: 5
Score: 0
Joined: 3/21/2006
Status: offline
dm you're a STAR!!!!

Works a treat now exactly how I'd hoped...many many thanks for the pointers and code examples on this

thx all...

(in reply to dm_4ever)
 
 
Post #: 7
 
 RE: User Account Wildcards? - 2/15/2007 7:02:22 AM   
  dm_4ever


Posts: 2359
Score: 36
Joined: 6/29/2006
From: Orange County, California
Status: offline
thanks. glad to be of some help.

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to zym1ne)
 
 
Post #: 8
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> User Account Wildcards? Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts