bstillion
asked on
How do I test this restart all PCs script?
Kixtart version 4.21.0.0
I want to use the following syntax to restart all domain PCs (256, Win2k and WinXP) but not the servers.
All PC names start with SHH and then 4 digits and the servers do not. I'm not sure how I can test each line of code before the mass restart:
$comps=COMNetView()
for each $comp in $comps
IF LEFT($comp,4) = "SHH_" or LEFT($comp,3) <> "SHH"
GOTO END
ENDIF
if $comp<>@WKSTA
$rc=fnWMIShutdown($comp,6)
endif
next
$rc=fnWMIShutdown(@WKSTA,6 )
:END
I want to use the following syntax to restart all domain PCs (256, Win2k and WinXP) but not the servers.
All PC names start with SHH and then 4 digits and the servers do not. I'm not sure how I can test each line of code before the mass restart:
$comps=COMNetView()
for each $comp in $comps
IF LEFT($comp,4) = "SHH_" or LEFT($comp,3) <> "SHH"
GOTO END
ENDIF
if $comp<>@WKSTA
$rc=fnWMIShutdown($comp,6)
endif
next
$rc=fnWMIShutdown(@WKSTA,6
:END
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
my bad, make that a space delimited list, not comma delimited in $list_of_Servers
ASKER
Isorg:
I needed to research the syntax to understand how it all works. I did not know how to
process the UDF but have read up on it at kixtart.org/forums.
Now that I understand, I will test this tomorrow (with a space delimited list of servers
as you suggest.)
bstillion
I needed to research the syntax to understand how it all works. I did not know how to
process the UDF but have read up on it at kixtart.org/forums.
Now that I understand, I will test this tomorrow (with a space delimited list of servers
as you suggest.)
bstillion
ASKER
I have not yet found a way to test the COMNetView() UDF. I was attempting to send the list to a text file but without luck (using REDIRECTOUTPUT().) At this point I will try to at least echo the list to the console to confirm that the servers are excluded.
bstillion
bstillion
ASKER
By using REDIRECTOUTPUT(), the list echos to the screen. The list is a string of 0s though. Any thoughts on what needs to change to actually see the list of computers generated by the COMNetView() UDF?
(I was able to test the other UDF successfully: fnWMIShutdown)
bstillion
(I was able to test the other UDF successfully: fnWMIShutdown)
bstillion
the COMNetView() udf returns an array.
use his code example to dump out the array...
for each $comp in $comps
? $comp
next
or....
use the join() cmd.
? join($comps,@crlf)
use his code example to dump out the array...
for each $comp in $comps
? $comp
next
or....
use the join() cmd.
? join($comps,@crlf)
ASKER
Isorg:
Thanks for the help!
The script works great. I used the first example (? $comp) to echo to the screen.
bstillion
Thanks for the help!
The script works great. I used the first example (? $comp) to echo to the screen.
bstillion
ASKER
Thanks again!
Brad
Brad
I am not familiar with kix but when I would test shell scripts I would do something like test it by writing out to files and such. If I wanted to just test that portion I would simply exit out or put output to the screen.