Closed action711 closed 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.
use "$PSVersionTable.PSVersion" and "$PSVersionTable.PSEdition" to validate.
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.
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.
Im going to go ahead and close this as of lack of response.
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
}}
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 }}