tomohulk / WinSCP

WinSCP PowerShell Wrapper Module
GNU General Public License v3.0
156 stars 30 forks source link

Fallen at first hurdle #103

Closed action711 closed 5 years ago

action711 commented 5 years ago

Please fill in the following fields, replacing the values inside the brackets {{ }}.

Issue Description

{{ Installed it, but get errors on basic commands }}

Example

{{ I've installed it and am trying out basic commands, but just can't get anywhere at all

$sessionOption = New-WinSCPSessionOption -HostName website.com or New-WinSCPSessionOption -HostName website.com

}}

Expected Output

{{ Don't know, haven't used it before }}

Actual Output

{{ Method invocation failed because [System.Security.SecureString] does not contain a method named 'new'. At line:1 char:1

WinSCP-PowerShell Version

{{ 5.15.1.0 }}\

Environment

{{ Name : ConsoleHost Version : 4.0 InstanceId : 1cf56fdf-3adb-4016-ac40-04a44055860b UI : System.Management.Automation.Internal.Host.InternalHostUserInterface CurrentCulture : en-GB CurrentUICulture : en-US PrivateData : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy IsRunspacePushed : False Runspace : System.Management.Automation.Runspaces.LocalRunspace }}

jeffreymcclain commented 5 years ago

First try the easiest step of rebooting if you haven't already done so ;)

Second, try putting single quotes around your hostname, for example:

$sessionOption = New-WinSCPSessionOption -HostName 'website.com'

This might be needed if your hostname has special characters in it.

If that doesn't work, run "Get-InstalledModule" and see if the WinSCP module is listed and if it's the latest version. If not, run PowerShell as administrator and run the command "Install-Module -Name WinSCP". Close and reopen the PowerShell window, and possibly reboot to be on the safe side.

What OS are you using? Try updating to PowerShell 5.1 Desktop edition.

I just tested by running

$sessionOption = New-WinSCPSessionOption -HostName "google.com"

with no errors, so it's definitely either an issue with your environment or the particular hostname value you are using.

dotps1 commented 5 years ago

It does sound like your environment is quite dated. Perhaps ill up the minimum required version of PowerShell to v5. v4 is very dated. Basically, when you use the New-WinSCPSessionOption with no -Credential parameter value, it creates a default credetinal. And there is no method for [System.Security.SecureString]::new().

but you really should think about updating your PowerShell version. I mean v7 is upon us.

dotps1 commented 5 years ago

Im going to go ahead and close this as of lack of response.