PowerCLI

 View Only
  • 1.  posh-ssh

    Posted Feb 17, 2020 01:55 PM

    Hi Luc ,

    is there any known issue with posh-ssh module

    i am trying to use invoke-sshcommand using session id 0 (that should be the first session id )

    i belive 0 should be considered as the session id .(ZERO HAS GREAT SIGNIFICANCE IN MATHEMATICS)

    PS C:\> $session_vcsa=New-SSHSession -ComputerName vcsa-01a.corp.local -Credential $cred_root

    PS C:\> $session_vcsa.SessionId

    0

    PS C:\> $conlib=Invoke-SSHCommand -Command "service-control --status vmware-content-library" -SessionId $session_vcsa_id

    Invoke-SSHCommand : Cannot bind argument to parameter 'SessionId' because it

    is null.

    At line:1 char:97

    + ... -control --status vmware-content-library" -SessionId $session_vcsa_id

    +                                                          ~~~~~~~~~~~~~~~~

        + CategoryInfo          : InvalidData: (:) [Invoke-SSHCommand], ParameterB

       indingValidationException

        + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,I

       nvoke-SSHCommand



  • 2.  RE: posh-ssh
    Best Answer

    Posted Feb 17, 2020 02:09 PM

    Not sure what you are doing there, but the error states that variable $session_vcsa_id contains $null, not 0.
    I don't see you assigning any value to $session_vcsa_id, hence it contains $null (as any uninitialised, non-typed variable)

    In fact, when I test with the number 0, it works

    SSHCommand -Command "service-control --status vmware-content-library" -SessionId 0



  • 3.  RE: posh-ssh

    Posted Feb 17, 2020 03:16 PM

    i am going to check this again .i think i did not pass the right variable which has value zero in it .thats why it took null.

    however i am getting below

    PS C:\Windows\system32> New-SSHSession -ComputerName vcsa-01a.corp.local -Credential(Get-Credential)

    cmdlet Get-Credential at command pipeline position 1

    Supply values for the following parameters:

    New-SSHSession : Permission denied (keyboard-interactive).

    At line:1 char:1

    + New-SSHSession -ComputerName vcsa-01a.corp.local -Credential(Get-Cred ...

    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        + CategoryInfo          : SecurityError: (Renci.SshNet.SshClient:SshClient) [New-SSHSessio

       n], SshAuthenticationException

        + FullyQualifiedErrorId : SSH.NewSshSession

    even i cant login to vami with root .



  • 4.  RE: posh-ssh

    Posted Feb 17, 2020 03:29 PM

    That looks like a credential issue.
    Can you add the -Verbose switch?



  • 5.  RE: posh-ssh

    Posted Feb 18, 2020 06:02 PM

    It worked fine when I tested last .variable had value zero and hence session I’d zero.