I have an existing Powershell script which works without issue in PowerShell 5.1. After installing PowerShell 7, the script no longer works and it fails when trying to establish a WinSCP session.
First, session options are created via New-WinSCPSessionOption, and those options are stored to $sessionOption without issue.
$sessionOption = New-WinSCPSessionOption -HostName $hostName -Credential $credentials -Protocol Ftp
When the session setup runs, an exception is thrown in Powershell 7:
$session = New-WinSCPSession -SessionOption $sessionOption
The following exception is thrown:
Line |
| $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)'."