Solved

psexec script

Posted on 2013-11-06
10
864 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
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
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

The problems with reply email signatures

Do you wish that you could place an email signature under a reply? Well, unfortunately, you can't. That great Exchange/Office 365 signature you've created will just appear at the bottom of an email chain. What a pain! Is there really no way to solve this? Well, there might be...

Question has a verified solution.

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

Scenario:  You do full backups to a internal hard drive in either product (SBS or Server 2008).  All goes well for a very long time.  One day, backups begin to fail with a message that the disk is full.  Your disk contains many, many more backups th…
Setting up a Microsoft WSUS update system is free relatively speaking if you have hard disk space and processor capacity.   However, WSUS can be a blessing and a curse. For example, there is nothing worse than approving updates and they just have…
This tutorial will give a an overview on how to deploy remote agents in Backup Exec 2012 to new servers. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as connecting to a remote Back…
This tutorial will walk an individual through the steps necessary to configure their installation of BackupExec 2012 to use network shared disk space. Verify that the path to the shared storage is valid and that data can be written to that location:…

895 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

11 Experts available now in Live!

Get 1:1 Help Now