Quantcast
Channel: THWACK: Discussion List - All Communities
Viewing all articles
Browse latest Browse all 16365

PsExec.exe through SAM Template using Windows Script Monitor Component

$
0
0

I have created a SAM Template using the Windows Script Monitor Component running VBScript against a windows server.

 

Here is the code:

Set objShell = CreateObject("WScript.Shell")
counter = 0

Set objScriptExec = objShell.Exec("C:\psexec\pstools\psexec.exe \\${IP} -u ${USER} -p ${PASSWORD} -accepteula netstat -an")
Do While Not objScriptExec.StdOut.AtEndOfStream
   results = objScriptExec.StdOut.ReadLine()   if instr(results, "TIME_WAIT")>0 then      counter = counter + 1    end if
Loop

msg = ""
Do While Not objScriptExec.StdErr.AtEndOfStream
   msg = msg & objScriptExec.StdErr.ReadLine()
Loop

wscript.echo "Message: " & msg
wscript.echo "Statistic: " & counter

 

The purpose of the code is to execute netstat on the target server which we are monitoring and count the number of "TIME_WAIT" connections exist and return the count.

PsExec.exe exists on the Solarwinds server at the location C:\psexec\pstools\

The credentials used are the same for both the Solarwinds server and the Target server to be monitored.

 

This WORKS! But only if I remote into the Solarwinds server with the user that I am using as the credentials.  If the user isn't remote desktop connected into the Solarwinds server, this is the error returned:

PsExec v2.11 - Execute processes remotely
Copyright (C) 2001-2014 Mark Russinovich
Sysinternals - www.sysinternals.com
The handle is invalid.
Connecting to xx.xx.xxx.x...
Starting PSEXESVC service on xx.xx.xxx.x...
Connecting with PsExec service on xx.xx.xxx.x...
Error deriving session key

 

All is irrelevant except for line 08. Error deriving session key.  This will go away when it works.

 

Why is it not working if the account is not logged in through remote desktop to the Solarwinds server?  Is there something I am doing wrong? Can I change something to make this work regardless if the account is logged in or not?

 

Thanks in advance,

 

Emran


Viewing all articles
Browse latest Browse all 16365

Trending Articles