Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Powershell script runs from command line but not as batch

$
0
0

Following is a sample of a powershell script that I can get to run fine from the powershell command line but not from within a software package that has the capacity to launch powershell scripts. Note that the “solaris” session specified in the snippet below is defined in PuTTY with applicable IP address. During runtime of the software package, the script does run up until the last line (it does some log file writing and some other processing not reflected in the snippet below). The last line is an attempt to logon to a remote machine and execute MyScript.sh. MyScript.sh never gets executed.

Additionally, what follows the sample script below in the software package ALSO never executes. Thus it appears that during run-time, the script below hangs on the last line. I thought adding the –batch would alleviate this, but not so.  Again the script runs fine from the powershell command line.

……………………………………………………………………………………………………………………………………………

Param

(

    [String]$USERID,

    [String]$USERNAME

)

    $myApp = "D:\plink.exe"

    [Array] $Creds = ("root", "<root-password>"), ("sysadmin", "<sysadmin-password>")

    $sshcommand = & $myApp -load solaris -batch -l $Creds[0][0] -pw $Creds[0][1] /root/SOFTWARE/MyScript.sh $USERID $USERNAME

Return ""

……………………………………………………………………………………………………………………………………………

I replaced the last line with the following and got the same results:

D:\plink.exe -batch -load solaris -l $Creds[0][0] -pw $Creds[0][1] /root/SOFTWARE/MyScript.sh $USERID $USERNAME

Any thoughts on what may be causing this issue and how to resolve? I appreciate that the issue might be a nuance of the software package that is launching the script, and I am posting on that forum as well. But also posting here in case the resolution is purely powershell-related. Thanks for any ideas!


Ramona Balke


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>