Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

Re: Method not found

WinSCP PowerShell Wrapper Module is thirdparty anyway, we cannot provide help here.
mcentyre

Tried Posh-SSH and I'm set

FYI, I rewrote the code test using Posh-SSH and its working. I still love WinSCP client, but I'll have to improve my coding skills before I return. Still just an amateur. No fix needed....thanks!
mcentyre

Method not found

Having a hard time figuring out what I'm doing wrong. I'm getting a "Method not found" error on a quickie test script for the WinSCP module.

WinSCP v5.17.3.0 is installed.
PowerShell v7.0
Visual Studio Code v1.44.2
WinSCP-5.17.3-Automation.zip

Test Code:
Import-Module WinSCP
$UN = "USERREMOVED"
$SPW = Get-Content "C:\Projects\CheckPull\IPSFiservCredentials.txt" | ConvertTo-SecureString
$Credentials = New-Object System.Management.Automation.PSCredential -ArgumentList $UN, $SPW
$SshHostKeyFingerprint = "ssh-dss 1024 REALSTUFFREMOVED"
$IPSFiserv = "SITEREMOVED"
$sessionOption = New-WinSCPSessionOption -HostName $IPSFiserv -Protocol Sftp -SshHostKeyFingerPrint $SshHostKeyFingerprint -Credential $Credentials
$session = New-WinSCPSession -SessionOption $sessionOption
$directory = $session.ListDirectory("PATHREMOVED")
foreach ($fileInfo in $directory.Files)
{
    Write-Host ("$($fileInfo.Name) with size $($fileInfo.Length), " +
        "permissions $($fileInfo.FilePermissions) and " +
        "last modification at $($fileInfo.LastWriteTime)")
}
Remove-WinSCPSession -WinSCPSession $session


I've tried placing the WinSCP files from the zip in the project folder as well as in the WinSCP install location.

Any advice on what step(s) I'm missing greatly appreciated!

The error message I receive:

New-WinSCPSession: C:\Projects\CheckPull\WinSCPCheckPull.ps1:8:12
Line |
8 | $session = New-WinSCPSession -SessionOption $sessionOption
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Exception calling "Open" with "1" argument(s): "Method not found: 'Void
| System.Threading.EventWaitHandle..ctor(Boolean, System.Threading.EventResetMode, System.String, Boolean ByRef,
| System.Security.AccessControl.EventWaitHandleSecurity)'."