Posh-SSH icon indicating copy to clipboard operation
Posh-SSH copied to clipboard

New-SSHRemotePortForward function not work

Open Ak74-577 opened this issue 8 years ago • 1 comments

PS D:\Posh-SSH> Get-SSHSession PS D:\Posh-SSH> New-SSHSession -ComputerName 192.168.3.42 -Credential root -Port 22

SessionId Host Connected


0      192.168.3.42                                                     True

PS D:\Posh-SSH> New-SSHRemotePortForward -LocalAdress 192.168.4.8 -LocalPort 1337 -RemoteAddress 192.168.5.6 -RemotePort 3389 -Index 0

Write-Verbose : Cannot bind argument to parameter 'Message' because it is null. At D:\Posh-SSH\PortForward.ps1:186 char:31

  •             Write-Verbose $session.index
    
  •                           ~~~~~~~~~~~~~~
    
  • CategoryInfo : InvalidData: (:) [Write-Verbose], ParameterBindingValidationException
  • FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.WriteVerboseCommand

PS D:\Posh-SSH>

New-SSHLocalPortForward and New-SSHDynamicPortForward work is no problem, only New-SSHRemotePortForward does not work, I hope to help solve, thank you very much

Ak74-577 avatar Jan 23 '18 08:01 Ak74-577

Did you find a solution to this... trying to portforward but get similar issue for example:

New-SSHRemotePortForward -LocalAdress 192.168.4.8 -LocalPort 1337 -RemoteAddress 192.168.5.6 -RemotePort 3389 -Index 0

Throws error

Write-Verbose : Cannot bind argument to parameter 'Message' because it is null.
At C:\Program Files\WindowsPowerShell\Modules\Posh-SSH\2.2\Posh-SSH.psm1:2704 char:31
+                 Write-Verbose $session.index
+                               ~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Write-Verbose], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.WriteVerboseCommand

`New-SSHRemotePortForward -LocalAdress 192.168.4.8 -LocalPort 1337 -RemoteAddress 192.168.5.6 -RemotePort 3389 -sshSession $CurrentSession

Throws error

Exception calling "Start" with "0" argument(s): "Port forwarding for '192.168.5.6' port '3389' failed to start."
At C:\Program Files\WindowsPowerShell\Modules\Posh-SSH\2.2\Posh-SSH.psm1:2724 char:17
+                 $SSHFWP.start()
+                 ~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : SshException

Note: I can portforward in a batch script and in git bash, issue is just when using this

Powershell version: 5.1.18362.752 Posh-ssh version: 2.2 from PSGallery OS: Windows 10

dav101 avatar Oct 01 '20 16:10 dav101