darkoperator / Posh-SSH

PowerShell Module for automating tasks on remote systems using SSH
BSD 3-Clause "New" or "Revised" License
980 stars 227 forks source link

Unable to install the module Posh-ssh in Windows server #431

Open lakshmo123 opened 2 years ago

lakshmo123 commented 2 years ago

Install-Module -Name posh-ssh -Force

showing the error as the term is not recognized as the name of a cmdlet

MVKozlov commented 2 years ago

what does Get-Command Install-Module show ? what does $PSVersionTable show ?

lakshmo123 commented 2 years ago

Get-Command Install-Module Get-Command : The term 'Install-Module' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1

$PsVersiontable

Name Value


PSVersion 4.0 WSManStackVersion 3.0 SerializationVersion 1.1.0.1 CLRVersion 4.0.30319.36627 BuildVersion 6.3.9600.19170 PSCompatibleVersions {1.0, 2.0, 3.0, 4.0} PSRemotingProtocolVersion 2.2

MVKozlov commented 2 years ago

your powershell is v4.0 and you do not have powershellget installed so this is not posh-ssh problem

posh-ssh v3 does not support PSv4.0 but you can try

https://docs.microsoft.com/en-us/powershell/scripting/gallery/installing-psget?view=powershell-5.1#for-computers-running-powershell-30-or-powershell-40

darkoperator commented 2 years ago

You need to be running PowerShell 5.1 or Powershell 7. Powershell 4 is not supported

Sent from my iPhone

On Nov 15, 2021, at 4:47 AM, lakshmo123 @.***> wrote:

 Get-Command Install-Module Get-Command : The term 'Install-Module' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1

Get-Command Install-Module CategoryInfo : ObjectNotFound: (Install-Module:String) [Get-Command], CommandNotFoundExceptio n FullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Commands.GetCommandCommand $PsVersiontable

Name Value

PSVersion 4.0 WSManStackVersion 3.0 SerializationVersion 1.1.0.1 CLRVersion 4.0.30319.36627 BuildVersion 6.3.9600.19170 PSCompatibleVersions {1.0, 2.0, 3.0, 4.0} PSRemotingProtocolVersion 2.2

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

MVKozlov commented 2 years ago

@darkoperator It's funny, if remove Convert-SSHRegistryToJsonKnownHost и Get-SSHRegistryKnownHost (since they use classes) and lower the requirements for the version of the version to 4.0, it seems work :) at least it connects. just tested it

darkoperator commented 2 years ago

Never expected.net standard to be that good

Sent from my iPhone

On Nov 15, 2021, at 8:37 AM, Max Kozlov @.***> wrote:

 @darkoperator It's funny, if remove Convert-SSHRegistryToJsonKnownHost и Get-SSHRegistryKnownHost (since they use classes) and lower the requirements for the version of the version to 4.0, it seems work :) at least it connects. just tested it

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

MVKozlov commented 2 years ago

.net standard 2.0 for win is just net 4.61+ :) https://docs.microsoft.com/en-us/dotnet/standard/net-standard

lakshmo123 commented 2 years ago

your powershell is v4.0 and you do not have powershellget installed so this is not posh-ssh problem

posh-ssh v3 does not support PSv4.0 but you can try

https://docs.microsoft.com/en-us/powershell/scripting/gallery/installing-psget?view=powershell-5.1#for-computers-running-powershell-30-or-powershell-40

I need to run a few commands and export them into an excel file in the putty session. In which I need to connect the putty from RDP. so I need to install the posh-ssh module in order to run the script. Do I need to install the PowerShell 5.0?

MVKozlov commented 2 years ago

If your host can be connected by Posh-SSH v2, you can install it manually or thru Save-Module from other computer with PSv5.1

Save-Module -Name Posh-SSH  -MaximumVersion 2.3 -Path d:\

where d:\ - path where module should be saved (D:\Posh-SSH\2.3.0)

or, if host supported only by Posh-SSH v3 (host signature not RSA), You need PS v5.1 or PSv7+

MVKozlov commented 2 years ago

@darkoperator, btw it seems to me that v3 should be published here in Releases