From: Al Dunbar [MS-MVP] on

"Arsi" <fitz76poista.tama(a)hotmail.com> wrote in message
news:cud9tt$gec$1(a)phys-news1.kolumbus.fi...
> Torgeir Bakken (MVP) wrote:
>
> >
> > Hi
> >
> > As the current user account only have ordinary user rights, the
> > script will not be able to add the account to a group.
> >
> > You could do it in a computer startup script (with a GPO) that runs
> > as part of the boot up process (before the user logs in). It runs
> > under the system context and has admin rights.
> >
> >
>
> This works, thanks.
>
> Now I tried to restrict this more so that everyone would not be local
> "Power User" in the domains every computer. So I figured out that what
> about reading the information from a file and then adding certain users
> only to their own computers. I mean that we have a machine database
> where we could export our user / machine information and use it to make
> everyone local "Power User" of their own computer.
>
> So I tried this script. It works fine if there's only 1 line of text.
> When you have multiple users / computers in the text file then it only
> reads the last line of the text file =/

Not so - see below....


> How could I accomplish this so that I could only read the line that
> concerns the current user/machine (strUser = objNet.UserName and
> strComputer = objNet.ComputerName)? Am I thinking this the wrong way,
> could there be an easier solution to do this?
>
> Hmm... if this "thing" can be done will it work if the user has multiple
> computers, like Desktop and Laptop?
>
>
> beginning of the script
> '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
> Set objNet = CreateObject("WScript.NetWork")
> Dim strComputer
> Dim strUser
> strComputer = objNet.ComputerName
> strUser = objNet.UserName
>
> Const ForReading = 1
> Set objFSO = CreateObject("Scripting.FileSystemObject")
> Set objTextFile = objFSO.OpenTextFile ("C:\Test.txt", ForReading)
> Do Until objTextFile.AtEndOfStream
> strNextLine = objTextFile.Readline
> arrServiceList = Split(strNextLine , ",")
> For i = 1 to Ubound(arrServiceList)
> Next

What useful work does the above for next loop actually do for you?

> Loop

The do loop above reads through the entire file. The last value placed into
the strNextLine variable and the arrServiceList array simply remains there
until it gets to the code that follows:

> if strUser = arrServiceList(0) and strComputer = arrServiceList(1) then
>
> Set objGroup = GetObject("WinNT://" & strComputer & "/Power Users")
> Set objUser = GetObject("WinNT://MyDomain/" &strUser)
> objGroup.Add(objUser.ADsPath)
>
> end if
> '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
> end of the script

If you want the above if block to be repeated for different data read in
from the file, then you need to move it into the do loop

/Al

>
>
> Test.txt
> '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
> user1,computer1
> user2,computer2
> user3,computer3
> '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''


From: Arsi on
Thanks Al, I got it working! I'm not sure if it's very "nice" but it's
working. I made two do loops and that did the trick for me. Removed
those two extra lines too (For i = 1 to Ubound(arrServiceList) and Next).

I'll post it later if you want to see it. As a matter of fact, I would
like to have some comments about it because I'm not a vbs/wsh/scripting
"guru".


/Arsi
From: Al Dunbar [MS-MVP] on

"Arsi" <fitz76poista.tama(a)hotmail.com> wrote in message
news:cufsku$1nl$1(a)phys-news1.kolumbus.fi...
> Thanks Al, I got it working! I'm not sure if it's very "nice" but it's
> working. I made two do loops and that did the trick for me. Removed
> those two extra lines too (For i = 1 to Ubound(arrServiceList) and Next).
>
> I'll post it later if you want to see it. As a matter of fact, I would
> like to have some comments about it because I'm not a vbs/wsh/scripting
> "guru".

Please do, we promise to be "gentle".

/Al


From: Arsi on
Al Dunbar [MS-MVP] wrote:
>
>
> Please do, we promise to be "gentle".
>
> /Al
>
>

Hehe ;)


Here it goes:

'''''''''''''''''''''''''''''''''''''''''''''''
Dim strComputer
Dim strUser
Set objNet = CreateObject("WScript.NetWork")

strComputer = LCase(objNet.ComputerName) 'converting to lowercase
strUser = LCase(objNet.UserName) 'converting to lowercase

Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile ("\\MyDC\Netlogon\Test.txt",
ForReading)

'read entire text file, split username and computername with ","
Do until objTextFile.AtEndOfStream
strNextLine = objTextFile.Readline
arrServiceList = Split(strNextLine , ",")


Do While strUser = arrServiceList(0) and strComputer =
arrServiceList(1)
On Error Resume Next
Set objGroup = GetObject("WinNT://" &
strComputer & "/Power Users")
Set objUser = GetObject("WinNT://MyDomain/"
&strUser)
objGroup.Add(objUser.ADsPath)

Exit Do
Loop

Loop
'''''''''''''''''''''''''''''''''''''''''''''''
From: didier Danel on


Ok , your script run if the domain is an NT4 , but if the domain is an
AD2003 you must bind the AD with the LDAP://SERVER:389/cn.... and after
the ADSPAth don't work.

I must write a vbs script to this and i don't get a good result.

thanks

Didier DANEL

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
First  |  Prev  |  Next  |  Last
Pages: 1 2 3
Prev: GetDetailsOf
Next: ERROR_ACCESS_DENIED5 (00000005)