Page 1 of 1 1
Topic Options
#85172 - 2002-02-28 05:35 PM Create LocalGroup
MadDawgMike Offline
Fresh Scripter

Registered: 2002-01-18
Posts: 9
Loc: Durham, NC
I haven't seen this yet, and don't know if it is possible with Kix.
I need to create a Local group on each of my many workstations. I have seen examples of adding users to local groups, and checking membership in them. Is there any way to create a Local Group on the workstation with ADSI? What about another method from within Kix?

Mike

Thanks in advance for any help with this.

Top
#85173 - 2002-02-28 06:18 PM Re: Create LocalGroup
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
you can do this from the ADSI interface. I don't have the time right at this moment, later today i will.

Chances are Shawn will beat me to it.

Top
#85174 - 2002-02-28 06:47 PM Re: Create LocalGroup
MasterOfDesaster Offline
Fresh Scripter

Registered: 2002-01-23
Posts: 21
Loc: Munich, Germany
Hi,

you can use following code to create groups on PCs

code:
  

;Create Group
$oComputer=GetObject("WinNT://Computername,computer") ;Replace the computername with your real pc name
$oGroup=$oComputer.Create("group","Groupname")
$oGroup.Put("grouptype",4) ;2=global(in domain) and 4=lokal
$oGroup.setinfo

;Add Users

$oGroup.add("WinNT://Domain/Username")


;show group members

for each $e in $oGroup.members
? $e.name
next


I hope it helps

_________________________
Greetings,

Michael

Top
#85175 - 2002-02-28 09:09 PM Re: Create LocalGroup
MadDawgMike Offline
Fresh Scripter

Registered: 2002-01-18
Posts: 9
Loc: Durham, NC
Thanks for the responses Guys
What I am trying to do is run a script that reaches out to each machine listed in clist.dat (all in my domain), and create a LocalGroup. Then Add a certain DomainGroup to that LocalGroup. I used Michael's code snippet, but don't know enough about ADSI to know if I am doing this right.

I have Tried and tried, but get the same error:

Script error : unknown command !
$Group=$Computer.Create("group",$LocalGrp)

Here is the code:

code:

$ComputerName = ReadLine(1)
?"Enter Local Group to create on each Machine: " Gets $LocalGrp

;********* Do Stuff to each Machine in list ***********
Do

;Create Group
$Computer=GetObject("WinNT://$Domain/$ComputerName,computer") ;Replace the computername with $CompuerName from clist.dat
;Info For Testing

?"Machine: " + $ComputerName
?"New group: " + $LocalGrp
?""

$Group=$Computer.Create("group",$LocalGrp)
$Group.Put("grouptype",4) ;2=global(in domain) and 4=local
;Add Users
$Group.add("WinNT://$Domain/CSUP-Local")
$Group.setinfo
;show group members
For Each $e in $oGroup.members
? $e.name
Next


I hope this comes out right, it is my first time attempting to post code to this board.

Mike

Top
#85176 - 2002-02-28 11:24 PM Re: Create LocalGroup
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
i think you have some type of syntax error going on.

this line is the problem.

$Computer=GetObject("WinNT://$Domain/$ComputerName,computer")

what is happening is the variable $computer is not being assigned to a com object, so when you try $computer.create you get an error.

change that line to this.

$Computer=GetObject("WinNT://$Domain/$ComputerName","computer")

And always check to make sure that the com object was loaded right.

code:

if valtype($computer) <> 9
? "warning!! unable to load COM object!!"
exit(1)
endif

Bryce

[ 28 February 2002: Message edited by: Bryce ]

Top
#85177 - 2002-03-08 05:24 PM Re: Create LocalGroup
MadDawgMike Offline
Fresh Scripter

Registered: 2002-01-18
Posts: 9
Loc: Durham, NC
Bryce,
Thanks for the help, the line you picked out seems to be working properly as I have it. When I made your change it gave me an error about 'wrong number of arguments..' or something to that effect.

I did add your error code and actually used it as an example for some other checking I needed! You guys are GREAT!! [Big Grin]

This script allowed me to 'visit' about 950 machines in less than an hour for the update and also used it to seed a script for our helpdesk to use to add users to the local groups.

I can post the code if anyone is interested.
Many thanks again!

Mike

Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 2312 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.057 seconds in which 0.028 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org