Page 1 of 1 1
Topic Options
#145565 - 2005-08-12 03:00 PM Expected Expression
burnsc Offline
Starting to like KiXtart

Registered: 2004-04-14
Posts: 171
Alright... I am about insane(not that is that far to go )
I SWEAR I can not see the problem here. The following gives me a expected expression error on the first line.
Code:

If (UserInLocalGroup($ComputerName, "Users" , "Domain Users") = True)
? "Domain Users present on " + $Computer
EndIf

Function UserInLocalGroup($ComputerName, $Group, $User)
$GroupObj = GetObject("WinNT://" + $ComputerName + "/" + $Group)

$FlagFound = False;
For Each $UserObjG IN $GroupObj.Members
If $UserObjG.Name = $User
$FlagFound = True
EndIf
Next
$UserInGroup = $FlagFound
EndFunction


Top
#145566 - 2005-08-12 03:03 PM Re: Expected Expression
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
If UserInLocalGroup($ComputerName, "Users" , "Domain Users") = 'True'
...
$FlagFound = 'False'
...
$FlagFound = 'True'
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#145567 - 2005-08-12 03:08 PM Re: Expected Expression
burnsc Offline
Starting to like KiXtart

Registered: 2004-04-14
Posts: 171
This change gives me the same error. It is happening before it runs the function code. I placed a get in the first line of the function for testing. It never makes it there.

Any more ideas?

Thanks

Top
#145568 - 2005-08-12 03:21 PM Re: Expected Expression
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Not saying this is what is throwing the error, but you call the UDF UserInLocalGroup() but the failed return is $UserInGroup.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#145569 - 2005-08-12 03:24 PM Re: Expected Expression
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Well, it shouldn't create an abend but the penultimate line is obviously wrong:
Code:
  $UserInGroup = $FlagFound



Recode it with SetOption("Explicit","ON") - it may help.


Edited by Richard H. (2005-08-12 03:26 PM)

Top
#145570 - 2005-08-12 03:29 PM Re: Expected Expression
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
I concur. If I run that snippet of code, I don't get any error.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#145571 - 2005-08-12 03:48 PM Re: Expected Expression
burnsc Offline
Starting to like KiXtart

Registered: 2004-04-14
Posts: 171
I caught that. It is fixed now.
Top
#145572 - 2005-08-12 03:49 PM Re: Expected Expression
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
i don't get an error either. I was thinking maybe the line actually throwing an error is not shown. You know when kix might say the error is on line 11, but the problem is actually on line 10...
Top
#145573 - 2005-08-12 03:49 PM Re: Expected Expression
burnsc Offline
Starting to like KiXtart

Registered: 2004-04-14
Posts: 171
that SetOption seems to have fixed it.

Thanks

Top
#145574 - 2005-08-12 03:54 PM Re: Expected Expression
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
so, did you find what was causing the error?
_________________________
!

download KiXnet

Top
#145575 - 2005-08-12 03:57 PM Re: Expected Expression
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
can we see your who script?
_________________________
!

download KiXnet

Top
#145576 - 2005-08-12 06:24 PM Re: Expected Expression
burnsc Offline
Starting to like KiXtart

Registered: 2004-04-14
Posts: 171
SURE <G>

Code:

$LogFileName = "%UserProfile%\NetworkDomainUsersMembership" + @MONTHNO + @MDayNo + @Year + ".log"
$ComputerList = <machine array>

For Each $Computer in $ComputerList
If (UserInLocalGroup($Computer, "Users" , "Domain Users") = 'True')
RemoveUserFromGroup($computer, "Users", "Corp\Domain Users")
EndIf
Next

Function UserInLocalGroup($ComputerName, $Group, $User)
$GroupObj = GetObject("WinNT://" + $ComputerName + "/" + $Group)

$FlagFound = 'False';
For Each $UserObjG IN $GroupObj.Members
If $UserObjG.Name = $User
$FlagFound = 'True'
EndIf
Next
$UserInLocalGroup = $FlagFound
EndFunction

Function WriteLog ($LogFile, $LogString)
If Open(1, $LogFile, 5) = 0
$LogString = "@MONTHNO.@MDayNo.@Year @TIME " + $LogString + @CRLF
$result = WriteLine (1, $LogString)
Close(1)
Else
BEEP
? "Failed to open Log file(Error[" + @Error + "]) "
EndIf
EndFunction

Function RemoveUserFromGroup($Computer, $Group, $User)
; Log the fact this machine has the group in its list and then remove it from the list
WriteLog($LogFileName, "$Computer contains " + Chr(34) + $User + Chr(34) + " in " + chr(34) + $Group + Chr(34))
$ShellStr = "C:\grpmaint.exe --Sam \\" + $Computer + " --remove --name $Group --member " + Chr(34) + "$User" + Chr(34) + " --logfile " + Chr(34) + "$LogFileName" + Chr(34)
Shell $ShellStr
EndFunction




I am sure I will be back for more on this, as this script will be much more powerful by the time it is done. I am hoping to have a 'control' file that will tell the script what to do on what machine. (ie machine = *, group = 'Domain*', user = 'corp\Domain Users' Action = Delete)

This is still VERY MUCH in baby stages.

Top
Page 1 of 1 1


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

Who's Online
0 registered and 978 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.062 seconds in which 0.024 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