?
Solved

psexec script

Posted on 2013-11-06
10
Medium Priority
?
894 Views
Last Modified: 2013-11-14
Is it possible to use psexec script to check tell whether a server is still alive or not ?

Can we use psexec script to shutdown a NT 4.0 server ?

Tks
0
Comment
Question by:AXISHK
[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
  • 4
10 Comments
 
LVL 53

Assisted Solution

by:Will Szymkowski
Will Szymkowski earned 668 total points
ID: 39629388
Instead of using psexec to accomplish this you might want to use psshutdown which should do the trick...

psshutdown - http://technet.microsoft.com/en-us/sysinternals/bb897541.aspx

If you want to know if a server is still alive in most cases a simple "ping" to the servers name or IP will tell you this. Sometimes ping can be false (when ping-able) if a server is unresponsive due to a stopped or halted service or core windows files are corrupt or damaged.

Will.
0
 
LVL 13

Assisted Solution

by:SagiEDoc
SagiEDoc earned 1332 total points
ID: 39629433
You can shutdow a remote machine from the command line using this:
shutdown -m \\machinename -r -f
-r = Restart.
-f = Close programs and force shutdown.
Out of interest -s will shut the machine down.

You could use a vb ping script to check if the servers are responding. The script below will ping a predefined list of servers and then write to a file the servers that did not respond. Save the following into a text file and save with .vbs

Option Explicit

Const ForReading = 1

Dim objFSO, objFile
Set objFSO = CreateObject("Scripting.FileSystemObject")

'List of hosts to ping - set path. Hosts listed in the file, one host per line.
Set objFile = objFSO.OpenTextFile("C:\path\hosts.txt", ForReading)

Dim fso, f1
Set fso = CreateObject("Scripting.FileSystemObject")

'List of hosts that did not respond. Set path.
Set f1 = fso.CreateTextFile("C:\path\noresponse.txt", True)



Dim Shell, strCommand, strHost, ReturnCode

'Host or IP to ping
Do Until objFile.AtEndOfStream
strHost = objFile.ReadLine

'Create shell object
Set Shell = wscript.createObject("wscript.shell")

'What to run in command line
strCommand = "ping -n 1 -w 300 " & strHost

'Run command and get return code
ReturnCode = Shell.Run(strCommand, 0, True)

'0 = pingable, 1 = no response
If ReturnCode <> 0 Then
f1.WriteLine ""& strHost &" is down"
End If
Loop

'Remove comment to have optional status message display when the script is complete.
'msgbox("Ping complete!")


Hope that helps.
0
 

Author Comment

by:AXISHK
ID: 39629617
Try the shutdown command but doesn't work..

10.0.20.26: The entered computer name is not valid or remote shutdown is not sup
ported on the target computer. Check the name and then try again or contact your
 system administrator.(53)


The workstation 10.0.20.26 can be pinged...

Any idea ?
0
What Is Blockchain Technology?

Blockchain is a technology that underpins the success of Bitcoin and other digital currencies, but it has uses far beyond finance. Learn how blockchain works and why it is proving disruptive to other areas of IT.

 
LVL 13

Expert Comment

by:SagiEDoc
ID: 39629633
Apologies, should look like this:

shutdown /m \\machinename /r /f

You will need permissions to run this you can not run as a normal user. A quick way to establish a connection to a remote server from the command line as an administrator is to do this:

net use \\machinename\c$ /user:domain\username password
0
 

Author Comment

by:AXISHK
ID: 39629669
Result for PsShutdown command.

C:\Scripts>psshutdown \\10.0.20.26 -f -t 10

PsShutdown v2.52 - Shutdown, logoff and power manage local and remote systems
Copyright (C) 1999-2006 Mark Russinovich
Sysinternals - www.sysinternals.com

Couldn't access 10.0.20.26:
The network path was not found.

Make sure that the default admin$ share is enabled on 10.0.20.26.

If 10.0.20.26 is already performing a shutdown operation you must
abort it before issuing a different command.
0
 
LVL 13

Expert Comment

by:SagiEDoc
ID: 39629740
Is the default admin share enabled?
0
 

Author Comment

by:AXISHK
ID: 39629998
Try net use \\machinename\c$ from my DC, it said network path not found.

The workstation is rebuilt without change anything and already granted to the domain. THe domain administrator has been added in the local adminstrators of the workstation.

Anything I can check ?

Tks
0
 
LVL 13

Expert Comment

by:SagiEDoc
ID: 39647087
It would appear the admin shares are not present. I am sure you could correct this with a GPO or script.
0
 

Author Comment

by:AXISHK
ID: 39647428
if i can access c$ on remote pc, does it mean admin share is opened?
0
 
LVL 13

Accepted Solution

by:
SagiEDoc earned 1332 total points
ID: 39647432
In all likelihood. But you can try \\machinename\admin$ this points to the windows folder. The admin$ share is what you need to be in place.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Learn about cloud computing and its benefits for small business owners.
A procedure for exporting installed hotfix details of remote computers using powershell
This tutorial will walk an individual through locating and launching the BEUtility application and how to execute it on the appropriate database. Log onto the server running the Backup Exec database. In a larger environment, this would generally be …
This tutorial will walk an individual through locating and launching the BEUtility application to properly change the service account username and\or password in situation where it may be necessary or where the password has been inadvertently change…
Suggested Courses
Course of the Month8 days, 14 hours left to enroll

764 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