【发布时间】:2020-03-19 10:03:21
【问题描述】:
我想在 WinSCP 中通过 PowerShell 保存会话,但我无法使用以下代码保存任何会话。保存会话可能是 PowerShell 代码错误。我想保存会话,每当我打开 WinSCP 时,我都可以看到该会话并能够登录到该会话。下面是代码截图:
try
{
# Load the assembly and setup the session properties
Add-Type -Path "C:\Program Files (x86)\WinSCP\WinSCPnet.dll"
# Session setup options
$sessionOptions = New-Object WinSCP.sessionOptions -Property @{
Protocol = ([WinSCP.Protocol]::Sftp)
HostName = "xxx.cloud.com"
UserName = "sftpuser_WIN_NPD"
PortNumber = "40022"
#Password = ""
SshPrivateKeyPath = "C:\key\sftp_private.ppk"
SshHostKeyFingerprint = "ssh-rsa 2048 0c:ce:5a:8a:82:f6:03:xx:xx:xx:xx:xx:xx:xx:xx:xx"
}
$session = New-Object WinSCP.session
}
catch
{
Write-Host "Error : $($_.Exception.Message)"
exit 1
}
请帮助我,在此先感谢:)
【问题讨论】:
标签: windows powershell winscp