Quantcast
Viewing latest article 4
Browse Latest Browse All 3454

Unable to get a remote Powershell script running

Ok I've now tried using powershell to do some remote checking and was trying to work out the process.

 

The script i was using is simple and is:

 

#

# script to compare the number of instances of a process with counts defined in

# c:\processLimitCount.txt on the target server

#

 

# gather the instance counts for all of the processes on a machine

 

$processList=Get-WmiObject win32_process | select ProcessName

 

$processCount = @{}

foreach ($process in $processList) {

  $processCount[$process.processName] = $processCount[$process.processName] + 1

}

 

# read inthe ol file from the server

 

$limitList=get-content 'c:\processLimitCount.txt'

 

# compare the instance count with the control file.

# Return 0 if all ok and 1 ifproblems in river city

 

$returnString = 0

foreach ($limit in $limitList) {

  if ( $processCount[$limit.substring(0,$limit.indexof("|"))] -ne $limit.substring($limit.indexof("|")+1) ) {

    $returnString = 1

  }

}

 

write-output $("Statistic: " + $returnString)

 

exit $returnString

 

I've placed it in a directory on the solarwinds server and tried it from a Powershell prompt:

 

PS C:\Users> invoke-command -filepath c:\udbdba\scripts\checkProcesses.ps1 -computername adbdb1dev -Credential "XXXXX"

Statistic: 0

PS C:\Users> invoke-command -filepath c:\udbdba\scripts\checkProcesses.ps1 -computername adbdb1dev -Credential "XXXXX"

Statistic: 1

 

Different values as I change the values in the file at the target machine . All looks good but I cant get it to run in Solarwinds

 

If I run it while in 'EDIT SCRIPT' I get Output Result: Not Defined

 

If I run it from the TEST button under component monitors I get 'Test failed with "DOWN" status on ....'

 

It looks like remote management is working on the remote server as I can run it in a powershell. Is there something else that needs to be configured in Solarwinds?


Viewing latest article 4
Browse Latest Browse All 3454

Trending Articles