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:
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:
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)'."