Solved

psexec script

Posted on 2013-11-06
10
854 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
  • 5
  • 4
10 Comments
 
LVL 53

Assisted Solution

by:Will Szymkowski
Will Szymkowski earned 167 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 333 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
 
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
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 333 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

I was supporting a handful of Windows 2008 (non-R2) 2 node clusters with shared quorum disks. Some had SQL 2008 installed and some were just a vendor application that we supported. For the purposes of this article it doesn’t really matter which so w…
Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…
This tutorial will show how to configure a single USB drive with a separate folder for each day of the week. This will allow each of the backups to be kept separate preventing the previous day’s backup from being overwritten. The USB drive must be s…

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now