|
|
|||||||
I konw there is a much better way to do this but just don't have the experience to know. I'd like to make an exclusion list so I don't run certain parts of my script on specified workstations IF NOT @WKSTA = "Workstation1" OR "Workstation2" OR "Workstation3" OR "etc" RUN SOME COMMAND ENDIF |
||||||||
|
|
|||||||
One way... See ComputerInGroup() - http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=84539 Code: If ComputerInGroup("SomeGroupName",@domain) ;do stuff Endif |
||||||||
|
|
|||||||
What if I want to include the computer names within the script? |
||||||||
|
|
|||||||
You asked for a better way... |
||||||||
|
|
|||||||
So I tried the syntax below but it only seems to register the first entry "Workstation1". Is there some reason the script would not pay attention to the following entries after "Workstation1"? In other words, it runs the command if it is run on Workstation2, 3, etc. IF NOT @WKSTA = "Workstation1" OR "Workstation2" OR "Workstation3" OR "etc" RUN SOME COMMAND ENDIF |
||||||||
|
|
|||||||
Okay... maybe this way then? Create an INI file and use EnumINI() - http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=135385 untested: Code: $excludedcomputers=EnumINI("File.ini") if ascan($excludedcomputers,@wksta)=-1 ;not in the excluded list, so do stuff else ;found the excluded computer, so skip this section endif |
||||||||
|
|
|||||||
The problem with what you are doing is, you are creating a mess and don't realize it. what you are asking for is something like... if @wksta="Workstation1" or @wksta="Workstation2" or @wksta="Workstation3" ...but when you start sticking Not in front of those with OR... the results are going to be something other than what you are expecting, not to mention hard to follow. |
||||||||
|
|
|||||||
I think this will work... not tested. Code: if not(@wksta="Workstation1" or @wksta="Workstation2" or @wksta="Workstation3") ;do stuff endif I hate this kind of code... my eyes cross and then I question what I did... if its right... Anyone else care to jump in here. |
||||||||
|
|
|||||||
Thanks Allen, As bad as it is, at least I see where my syntax was wrong. JEff. |
||||||||
|
|
|||||||
If you don't want to use external (ini) file then a simpler and more manageable way of implementing exclusion lists is with arrays: Code: $aExclusionList_1=Split("Workstation1,Workstation2,Workstation3",",") If 1+AScan($aExclusionList_1,@WKSTA) "Workstation "+@WKSTA+" is in exclusion list"+@CRLF Else "Workstation "+@WKSTA+" is not in exclusion list"+@CRLF EndIf |
||||||||
|
|
|||||||
I think Allen's first idea was the best. By creating a group and putting the computers you want to exclude in it, you just need to set up your script once. Later if you need to add another system, or remove one, you don't have to change your script. Rather, you just add or remove a computer from the group. I think it is much cleaner and easier to maintain. Regards, Brad |