#145565 - 2005-08-12 03:00 PM
Expected Expression
|
burnsc
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
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
If UserInLocalGroup($ComputerName, "Users" , "Domain Users") = 'True' ... $FlagFound = 'False' ... $FlagFound = 'True'
|
|
Top
|
|
|
|
#145567 - 2005-08-12 03:08 PM
Re: Expected Expression
|
burnsc
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
|
|
|
|
#145569 - 2005-08-12 03:24 PM
Re: Expected Expression
|
Richard H.
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
|
|
|
|
#145571 - 2005-08-12 03:48 PM
Re: Expected Expression
|
burnsc
Starting to like KiXtart
Registered: 2004-04-14
Posts: 171
|
I caught that. It is fixed now.
|
|
Top
|
|
|
|
#145573 - 2005-08-12 03:49 PM
Re: Expected Expression
|
burnsc
Starting to like KiXtart
Registered: 2004-04-14
Posts: 171
|
that SetOption seems to have fixed it.
Thanks
|
|
Top
|
|
|
|
#145576 - 2005-08-12 06:24 PM
Re: Expected Expression
|
burnsc
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
|
|
|
|
Moderator: Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 918 anonymous users online.
|
|
|