Page 1 of 1 1
Topic Options
#117103 - 2004-03-31 09:18 PM Local Group check for Domain Group
ktodi Offline
Getting the hang of it

Registered: 2002-03-29
Posts: 60
I am trying to write a select case statement that checks for the OS type then is supposed to check if a specific domain group exists in the local administrators group. What I have so far is posted here below. How do I write a statment that can verify the domain group domain\desktop team exist in the local administrators group.

$w2kwxp = @PRODUCTTYPE = "Windows 2000 Professional" OR @PRODUCTTYPE = "Windows XP Professional"

SELECT
CASE $w2kwxp = 0
GOTO ENDLGC
CASE ???domain group is in local group??? = true go to end, false continue to execute select statement
CASE INGROUP ("\\@WKSTA\Administrators")
SHELL '%ComSpec% /c net localGroup Administrators "domain\Desktop Admins" /Add'
ENDSELECT
;
:ENDLGC

Top
#117104 - 2004-03-31 09:32 PM Re: Local Group check for Domain Group
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Using the example from the KiXtart documentation..
Code:

IF INGROUP("\\" + @WKSTA + "\Developers") = 1
? "Member of Developers on local system"
ENDIF



You should be able to do this with no GOTOs.

Also, you have to be an Admin on the box you are trying to add this/these users to.

Kent

_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#117105 - 2004-03-31 09:45 PM Re: Local Group check for Domain Group
ktodi Offline
Getting the hang of it

Registered: 2002-03-29
Posts: 60
You reponse does not help. I am NOT trying to determine which groups the logged on user is part of. Please review my post for what I am trying to do.
Top
#117106 - 2004-03-31 09:49 PM Re: Local Group check for Domain Group
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
I think this is what you are looking for -
Code:

$Obj = GetObject("WinNT://"+@wksta+"/Administrators")
$Obj.Filter = Array("group")
For each $UserObj in $Obj.Members
?$UserObj.Name
Next


Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#117107 - 2004-03-31 10:07 PM Re: Local Group check for Domain Group
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Code:

CLS
BREAK ON
$domaingrp='YOUR DOMAIN GROUP'
$Obj = GetObject("WinNT://"+@wksta+"/Administrators")
For each $UserObj in $Obj.Members
;?$UserObj.Name
$dummyvar=$dummyvar+$UserObj.Name
;?$dummyvar
Next
IF INSTR($dummyvar,$domaingrp)=0
?'adding group'
ELSE
?'already there group'
ENDIF

?
?'Press a key..'
GET $k



Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#117108 - 2004-03-31 10:42 PM Re: Local Group check for Domain Group
ktodi Offline
Getting the hang of it

Registered: 2002-03-29
Posts: 60
Should the ; be removed from:
;?$UserObj.Name
and
;?$dummyvar

Doesn't UserOBJ = users I need to enumerate groups.

Top
#117109 - 2004-03-31 10:45 PM Re: Local Group check for Domain Group
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Yes you can remove the lines preceding with ";" as I was testing results.

$userobj can be replaced with $groupobj. My bad. It will give you the same results. Try the code.

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#117110 - 2004-03-31 11:07 PM Re: Local Group check for Domain Group
ktodi Offline
Getting the hang of it

Registered: 2002-03-29
Posts: 60
I get an unexcpected 'IN' error.
Top
#117111 - 2004-03-31 11:11 PM Re: Local Group check for Domain Group
ktodi Offline
Getting the hang of it

Registered: 2002-03-29
Posts: 60
Ignore my last post typo on my part.
Top
#117112 - 2004-03-31 11:20 PM Re: Local Group check for Domain Group
ktodi Offline
Getting the hang of it

Registered: 2002-03-29
Posts: 60
Ok here is the code i'm using im still getting the unexpected 'In" error.

$domaingrp = "corp\desktop admins"
$Obj = GetObject("WinNT://" + $WSname + "/Administrators")
For each $GroupObj.Name in $Obj.Members
?$GroupObj.Name
$Dummyvar = $Dummyvar + GroupObj.Name
?$Dummyvar
Next
IF INSTR($Dummyvar,$domaingrp) = 0
?"Add group"
ELSE
?"Group Already Added"
ENDIF

Top
#117113 - 2004-03-31 11:30 PM Re: Local Group check for Domain Group
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Try...

Code:

$domaingrp = "corp\desktop admins"
$Obj = GetObject("WinNT://" + $WSname + "/Administrators")
For each $GroupObj in $Obj.Members
?$GroupObj.Name
$Dummyvar = $Dummyvar + GroupObj.Name
?$Dummyvar
Next
IF INSTR($Dummyvar,$domaingrp) = 0
?"Add group"
ELSE
?"Group Already Added"
ENDIF


Top
#117114 - 2004-04-01 12:36 AM Re: Local Group check for Domain Group
ktodi Offline
Getting the hang of it

Registered: 2002-03-29
Posts: 60
I changed the line "$GroupObj.Name" to just "$GroupObj" and the in error wenat away. I'll test some more and let you know if it works.
Top
#117115 - 2004-04-01 12:43 AM Re: Local Group check for Domain Group
ktodi Offline
Getting the hang of it

Registered: 2002-03-29
Posts: 60
Ok the code works, somewhat. The group CORP\Desktop Admins is already in the Adminstrators group. When I run the script below I still get "Add Group". Any Ideas. How does the $Dummyvar statement work? if you don't mind droppin some knowledge on a fool.

$domaingrp = "CORP\Desktop Admins"
$Obj = GetObject("WinNT://" + $WSname + "/Administrators")
FOR EACH $GroupObj IN $Obj.Members
$Dummyvar = $Dummyvar + GroupObj.Name
Next
IF INSTR($Dummyvar,$domaingrp) = 0
?"Add group"
ELSE
?"Group Already Added"
ENDIF

Top
#117116 - 2004-04-01 12:52 AM Re: Local Group check for Domain Group
ktodi Offline
Getting the hang of it

Registered: 2002-03-29
Posts: 60
When I display the GroupOBJ.Name I only get Desktop Admins withouth the "CORP" that is why it cna't see it cause im looking for corp\desktop admins. Is there a way to get the domain name to be appended before the name?
Top
#117117 - 2004-04-01 12:56 AM Re: Local Group check for Domain Group
ktodi Offline
Getting the hang of it

Registered: 2002-03-29
Posts: 60
I spoke too soon changing the $domaingrp to "desktop admins" still reports "add group"
Top
#117118 - 2004-04-01 01:03 AM Re: Local Group check for Domain Group
ktodi Offline
Getting the hang of it

Registered: 2002-03-29
Posts: 60
I fixed it. Had to change the following line:
$Dummyvar = $Dummyvar + GroupObj.Name
to
$Dummyvar = $Dummyvar + $GroupObj.Name

Still I would like to be able to scify the domain with the group name not just the name of the group.

Top
#117119 - 2004-04-01 06:32 PM Re: Local Group check for Domain Group
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
something like this??

Code:

$grouptoadd = @DOMAIN + "\officelacky"


$Obj = GetObject("WinNT://" + @WKSTA + "/Administrators")
$obj.filter = "group",""
DIM $DomainGroups[0]
For Each $GroupObj In $Obj.Members
If Split($groupobj.adspath,"/")[3] <> @WKSTA
$DomainGroups[$i] = Split($groupobj.adspath,"/")[2] +"\" + Split($groupobj.adspath,"/")[3]
$i = $i + 1
ReDIM preserve $DomainGroups[$i]
EndIf
Next


If AScan($DomainGroups,$GroupToAdd) = -1
? $groupToAdd + " was not found in " + $obj.adspath
EndIf


Top
#117120 - 2004-04-02 01:33 AM Re: Local Group check for Domain Group
ktodi Offline
Getting the hang of it

Registered: 2002-03-29
Posts: 60
Bryce that was exactly what i was looking for, Thanks. Chris Thanks for all you help also I learned some things going through your script samples.
Top
Page 1 of 1 1


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

Who's Online
0 registered and 1471 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.07 seconds in which 0.026 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