Reputation: 665
I tried as below
$session = New-SSHSession -ComputerName $IPAddress -Credential $creds -AcceptKey
$result = Invoke-SSHCommand -SSHSession $session -Command "hostname"
The exception is as below
Invoke-SshCommand : A parameter cannot be found that matches parameter name 'SSHSession'.
+ $result = Invoke-SSHCommand -SSHSession $session -Command $updatepack ...
+ CategoryInfo : InvalidArgument: (:) [Invoke-SshCommand], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Invoke-SshCommand
I checked the documentation for the command and it was as below
SYNTAX
Invoke-SshCommand [[-ComputerName] <String[]>] [-Command] <String> [-Quiet] [-InvokeOnAll] [<CommonParameters>]
Invoke-SshCommand [[-ComputerName] <String[]>] [-ScriptBlock] <ScriptBlock> [-Quiet] [-InvokeOnAll] [<CommonParameters>]
I have seen examples with parameter name as SSHSession, not sure whether the module i imported is wrong version or not.
Upvotes: 0
Views: 5711
Reputation: 4174
I assume that you already have the Posh-SSH module. (Since you are not getting the Error : is not recognized as the name of a cmdlet)
I would advice you to check the version of the POSH-SSH
Get-module -Name Posh-SSH
Or
Get-command Invoke-SSHCommand
Check the version of the Posh-SSH Version.
Try updating to the latest one if you are in a very old version.
Install-Module -Name Posh-SSH -RequiredVersion 2.1
Upvotes: 1