Solved

How do I test this restart all PCs script?

Posted on 2008-06-16
9
343 Views
Last Modified: 2010-04-21
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
0
Comment
Question by:bstillion
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
9 Comments
 
LVL 3

Expert Comment

by:polazarus
ID: 21795893
You could try the workstation loop and write it out to a file and see if you get the desired result.

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.
0
 
LVL 3

Accepted Solution

by:
Isorg earned 500 total points
ID: 21797261
If you know a list of severs......

edit $list_of_servers to be a coma delimited list of the servers that you don't want to reboot.

and using goto's can just lead to bad coding :D
$comps=COMNetView()
 
$list_of_servers = 'server01,server02,server03,Secret_server'
 
for each $comp in $comps
	if not ascan(split($list_of_servers),$comp)+1
		;$comp is not a server in the $list_of_servers
		$rc=fnWMIShutdown($comp,6)
	ENDIF
next
$rc=fnWMIShutdown(@WKSTA,6)

Open in new window

0
 
LVL 3

Expert Comment

by:Isorg
ID: 21797280
my bad, make that a space delimited list, not comma delimited in $list_of_Servers
0
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 

Author Comment

by:bstillion
ID: 21798706
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
0
 

Author Comment

by:bstillion
ID: 21807069
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
0
 

Author Comment

by:bstillion
ID: 21807149
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
0
 
LVL 3

Expert Comment

by:Isorg
ID: 21807301
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)

0
 

Author Comment

by:bstillion
ID: 21807541
Isorg:
Thanks for the help!
The script works great. I used the first example (? $comp) to echo to the screen.



bstillion
0
 

Author Closing Comment

by:bstillion
ID: 31467698
Thanks again!

Brad
0

Featured Post

Why You Need a DevOps Toolchain

IT needs to deliver services with more agility and velocity. IT must roll out application features and innovations faster to keep up with customer demands, which is where a DevOps toolchain steps in. View the infographic to see why you need a DevOps toolchain.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ejb stateless example 2 66
print bytes of an integer 6 48
Crashing when deleting value with no child in Binary Tree 4 65
Developers / Staff Setup 10 40
This is an explanation of a simple data model to help parse a JSON feed
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question