tomohulk / WinSCP

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

The term 'New-WinSCPSessionOptions' is not recognized as the name of a cmdlet #154

Closed flaajimi closed 1 year ago

flaajimi commented 1 year ago

Hi,

I've downloaded an installed your plugin through the Install-Module cmdlet.

When I'm trying to run the code in your Example 1, with my server, user and password of course, I get a Powershell error:

New-WinSCPSessionOptions : The term 'New-WinSCPSessionOptions' 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.

Any ideas on what I might have configured incorrectly on my side, or is there a know problem that causes this error?

Import-Module WinSCP

$sessionOption = New-WinSCPSessionOption -HostName 10.10.10.207 -Protocol Sftp 

New-WinSCPSession -SessionOption $sessionOption
flaajimi commented 1 year ago

2023-08-29_16h18_54

tomohulk commented 1 year ago

Looks to me the module is not imported. I see you have used the code to import it, but maybe it's not actually importing. Use Get-Module and see if it actually exists in your session.

tomohulk commented 1 year ago

I just grabbed the latest and seems to be working fine for me:

image
flaajimi commented 1 year ago

I Have anothe message : image

Windows 8.1 image

tomohulk commented 1 year ago

It seems like your system is blocking something perhaps. I am unable to reproduce this issue.

But for starters I would update WMF, you have a very very old version of PowerShel. WMF 5.1 came out quite long ago: https://www.microsoft.com/en-us/download/details.aspx?id=54616

flaajimi commented 1 year ago

2023-08-31_13h04_30

flaajimi commented 1 year ago

I have a W8.1, the module is installed on image

tomohulk commented 1 year ago

Im not really sure what to say on this issue. I can't reproduce it, and this module has been around for like 7+ years and has over 1M downloads and this issue hasn't been reported until now. And the errors you are sharing suggest the module isn't even loading, so it not really anything to do with the logic inside it, its not getting that far. This leaves me to believe it's something with your system. And to me, it seems like something is being blocked. maybe the script module as well as the assembly itself. Check eventvwr and see if there is any errors that stand out there after you trying the Import-Module command.

Did you update your version of WMF? 5.0 is very old, 5.1 came out still in the days of windows 7. you could also try pwsh. this module is compatible with both.

flaajimi commented 1 year ago

It's OK now thanks

tomohulk commented 1 year ago

Can you share what you did to fix the issue should it come up for someone else.