I need to write a powershell script that will connect to plink.exe command line tool and it has to open a remote server using the IP address provided through powershell. The script which I tried is not showing me any error but it is also not able to connect to plink. The code is mentioned below, can anyone tell me where I am going wrong-
function plink
{
[CmdletBinding()]
PARAM
(
[Parameter(Mandatory=$True)]
[ValidateNotNullOrEmpty()]
[string] $remoteHost,
[Parameter(Mandatory=$True)]
[ValidateNotNullOrEmpty()]
[string] $login,
[Parameter(Mandatory=$True)]
[ValidateNotNullOrEmpty()]
[string] $passwd,
[Parameter(Mandatory=$True)]
[ValidateNotNullOrEmpty()]
[string] $command)
& "D:\plink.exe" -ssh $remoteHost -l $login -pw $passwd $command
return
}
$remoteHost = "172.21.3.185"
$login = "exchangelab/admin"
$command1 = "/opt/compiere/apache-tomcat-6.0.32/bin/shutdown.sh "
$command2 = "cd /opt/compiere/apache-tomcat-6.0.32/bin && ./startWS.sh"
$command3 = "ps -edalf | grep java"
$passwd = Read-Host "Enter Password for $login"
How can I call the plink function in my program? Thank you.