Required to "Run As Administrator" to open session
I am attempting to develop a Windows 10 Pro version 21H2 PowerShell script using the WinSCPnet.dll. I have WinSCP version 5.21 installed. I have used the code generator option to gather the
When I run the script from a PowerShell ISE as a user it crashes my PowerShell session. When I run the script from a Run As Administrator PowerShell ISE it runs as expected and does not crash my PowerShell session.
I am wanting to be able to run WinSCP in a script as a standard user. How can I make that happen?
SessionOptions
and used the basic examples to develop a simple PowerShell script, see below. Attached is my debug log.
When I run the script from a PowerShell ISE as a user it crashes my PowerShell session. When I run the script from a Run As Administrator PowerShell ISE it runs as expected and does not crash my PowerShell session.
I am wanting to be able to run WinSCP in a script as a standard user. How can I make that happen?
Clear-Content "C:\SVEC\Surveys\debug.log" $assemblyPath = if ($env:WINSCP_PATH) { $env:WINSCP_PATH } else { $PSScriptRoot } Add-Type -Path (Join-Path $assemblyPath "WinSCPnet.dll") $SessionOptions = New-Object WinSCP.SessionOptions -Property @{ Protocol = [WinSCP.Protocol]::Sftp HostName = "Data.inside-info.com" UserName = "xxxx" Password = "xxxx" SshHostKeyFingerprint = "ssh-ed25519 255 xxxxx" } $session = New-Object WinSCP.Session $session.DebugLogPath = "C:\SVEC\Surveys\debug.log" $session.ExecutablePath = "C:\SVEC\Surveys\WinSCP.exe" try{ # Connect $session.Open($sessionOptions) } catch { Write-Host "Error: $($_.Exception.Message)" } finally { # Disconnect & Clean up $session.Dispose() }