“was I putting files or getting files, location of the files that need to be placed on the server (d:newshare)”
This can be setup however you want. They will come out of cognos, be renamed, placed on whatever folder you want and then transferred into ToBankLabs on Abrigo’s side via WinSCP.
# Load WinSCP .NET assembly
try
{
$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
Add=Type -Path "D:WinSCPnet.dll"
# Set up session options
$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
Protocol = [WinSCP.Protocol]::Sftp
HostName = "constructsftp.abrigo.com"
UserName = "[email protected]"
SshPublicKeyFile = "C:sftpcommon_id_rsa.ppk"
SshHostKeyFingerprint = "ssh-ed25519 255 SHA256:fEbePT1DJOz+hH8KMW3NGGK8kBj6ss1Sm5lxBj+80Cs"
}
$session = New-Object WinSCP.Session
}
$session = New-Object WinSCP.Session
try
{
# Connect
$session.Open($sessionOptions)
# Download files
$transferOptions = New-Object WinSCP.TransferOptions
$transferOptions.TransferMode = [WinSCP.TransferMode]::Binary
$transferResult =
$session.GetFiles("*/toBankLabs/*.*", "D:app*", $False, $transferOptions) # Throw on any error
$transferResult.Check()
# Print results
foreach ($transfer in $transferResult.Transfers)
{
Write-Host "Download of $($transfer.FileName) succeeded"
}
}
finally
{
# Disconnect, clean up
$session.Dispose()
}
exit 0
}
catch
{
Write-Host "Error: $($_.Exception.Message)"
exit 1
}
Error PS D:WinSCP> C:Program Files (x86)WinSCPAbrigo.ps1
Error: Unable to find type [WinSCP.Protocol].
Upload or a Download of files in sftp to a directory on a remote server and local server.
Gary Langston is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.