{{ New-WinSCPSession : Cannot convert argument "sessionOptions", with value: "71319ftp@213.212.75.139", for "Open" to type "WinSCP.SessionOptions": "Cannot convert the
"71319ftp@213.212.75.139" value of type "WinSCP.SessionOptions" to type "WinSCP.SessionOptions"."
At F:\scripts\Backup\UpdateTest5.ps1:46 char:12
Receive-WinSCPItem : Cannot validate argument on parameter 'WinSCPSession'. The argument is null, empty, or an element of the argument collection contains a null value.
Supply a collection that does not contain any null values and then try the command again.
At F:\scripts\Backup\UpdateTest5.ps1:47 char:35
{{ Cannot convert argument "sessionOptions", with value: "71319ftp@213.212.75.139", for "Open" to type "WinSCP.SessionOptions": "Cannot convert the
"71319ftp@213.212.75.139" value of type "WinSCP.SessionOptions" to type "WinSCP.SessionOptions"."}}
Please fill in the following fields, replacing the values inside the brackets
{{ }}
.Issue Description
Cannot convert argument "sessionOptions", with value
Example
{{ # FTP Server Details $ftpHost = "Host" $username = "Username" $password = "Password" $sshFingerPrint = "ssh-rsa 1024 xxx xxx xxx"
Construct expected file name
$date = get-date $month =$date.tostring("MM") $day = $date.tostring("dd") $year = $date.tostring("yyyy") $time = "0000"
$filename = "qxqzepcjz_live_FullLLDB1A14$year$month$day$time.Lts.bak" $ftpFileDestination = "F:\tempdownload\fromftp"
Construct new database name
$restoredDatabaseName = 'LLDB_' + "$year$month$day" $restoredDatabaseFileName = $restoredDatabaseName + '.mdf' $restoredDatabaseLogFileName = $restoredDatabaseName + '_1.ldf'
Write-Host "Tetris Refresh Started: $date" -ForegroundColor "Green" Write-Host "--" Write-Host "FTP File: $filename" Write-Host "New DB: $restoredDatabaseName" Write-Host "New DB File: $restoredDatabaseFileName" Write-Host "New DB Log File: $restoredDatabaseLogFileName" Write-Host ""
- - - - Get database bak file from FTP Server - - - - -
$date = get-date Write-Host "Get database bak file from FTP Server Started: $date" -ForegroundColor "Green"
Add-Type -Path "C:\Program Files (x86)\WinSCP\WinSCPnet.dll" # Load the DLL
Start-Sleep -s 10 # Wait 10 seconds for the DLL to sort its life out
$sessionOptions = New-Object WinSCP.SessionOptions -Property @{ Protocol = [WinSCP.Protocol]::Sftp HostName = $ftpHost UserName = $username Password = $password SshHostKeyFingerprint = $sshFingerPrint }
$session = New-WinSCPSession -SessionOption $sessionOptions Receive-WinSCPItem -WinSCPSession $session -Path "$filename" -Destination $ftpFileDestination }}
Expected Output
{{ New-WinSCPSession : Cannot convert argument "sessionOptions", with value: "71319ftp@213.212.75.139", for "Open" to type "WinSCP.SessionOptions": "Cannot convert the "71319ftp@213.212.75.139" value of type "WinSCP.SessionOptions" to type "WinSCP.SessionOptions"." At F:\scripts\Backup\UpdateTest5.ps1:46 char:12
Receive-WinSCPItem : Cannot validate argument on parameter 'WinSCPSession'. The argument is null, empty, or an element of the argument collection contains a null value. Supply a collection that does not contain any null values and then try the command again. At F:\scripts\Backup\UpdateTest5.ps1:47 char:35
Actual Output
{{ Cannot convert argument "sessionOptions", with value: "71319ftp@213.212.75.139", for "Open" to type "WinSCP.SessionOptions": "Cannot convert the "71319ftp@213.212.75.139" value of type "WinSCP.SessionOptions" to type "WinSCP.SessionOptions"."}}
WinSCP-PowerShell Version
{{ ModuleType Version Name ExportedCommands
Script 5.15.9.0 WinSCP {ConvertTo-WinSCPEscapedString, Copy-WinSCPItem, Get-WinSCPChildItem, Get-WinSCPHostKeyFingerprint...}
}}\
Environment
{{ Server 2016 Datacenter, PS: 5.1.14393.3471, WinSCP }}