-1

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.

Makar Emelyanov
  • 167
  • 5
  • 16
user3568228
  • 9
  • 3
  • 6
  • 1
    Well ... Where is the call to your plink function in your script? – David Brabant Jun 12 '14 at 07:09
  • Do you just forgot to call the function ! – JPBlanc Jun 12 '14 at 07:26
  • You already posted a question about this same subject [yesterday](http://stackoverflow.com/questions/24155838/use-of-plink-in-powershell) – alroc Jun 12 '14 at 12:34
  • This question is redundand. You have not looked into how to do Powershell scripting and just copied and pasted that code from somewhere. Do your research, Google around. Look up "Powershell tutorials" and you will find your answer. – Makar Emelyanov Nov 12 '15 at 12:47

1 Answers1

0

You've declared a function and you've declared variables but you have not put any of them in to action by calling the function. If this answer doesn't make sense, I recommend this further reading: Powershellpro.com function tutorial

GrnMtnBuckeye
  • 214
  • 2
  • 4