Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

Southjam

Re: Could not load file or assembly

namerg wrote:

Hello,
I am trying to upload a file to an ftp site using winscp 5.1.5 through PowerShell but get the following error:
Could not load file or assembly 'WinSCP.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)


you have to add the path to where the dll is located.
# Load WinSCP .NET assembly
Add-Type -Path "C:\Program Files (x86)\WinSCP\WinSCPnet.dll"
this is for a 64 bit machine of course.
martin

Re: Could not load file or assembly

namerg wrote:

Hello,
I am trying to upload a file to an ftp site using winscp 5.1.5 through PowerShell but get the following error:
Could not load file or assembly 'WinSCP.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)

See https://winscp.net/forum/viewtopic.php?t=12006
If it does not help, please continues on that topic. This topic is not relevant to your problem.
namerg

Could not load file or assembly

Hello,
I am trying to upload a file to an ftp site using winscp 5.1.5 through PowerShell but get the following error:
Could not load file or assembly 'WinSCP.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
martin

Re: Powershell Script and WinSCP

Juneb wrote:

Thanks, I noticed the assemblies after i published the forum note. We are running 4.2.9 of winscp at the moment. Is the .Net Assemblies available with 4.2.9, or just the later versions of winscp?

Just 5.x.
Juneb

Re: Powershell Script and WinSCP

Thanks, I noticed the assemblies after i published the forum note. We are running 4.2.9 of winscp at the moment. Is the .Net Assemblies available with 4.2.9, or just the later versions of winscp?
Juneb

Powershell Script and WinSCP

Hi All -

I was wondering if i could get some assistance with a powershell/winscp script I am building. It will run in task scheduler every hour, daily, between a certain time slot. The script works - meaning it connects to the remote site and downloads the file(s). What I need, or would like is to pull the file names that were downloaded from the log file created by winscp, and have the names in the email body. Below is the sample script...any help is appreciated.





Clear-Host

$date = Get-Date -format "yyyy-MM-dd HH"
$BaseDir = "SomePath\"
$FileDir = "SomePath\"

Set-location $BaseDir

# Get File - Time Set in Task Scheduler
.\WinSCP.exe /console username@somewhere.com /script=Script.txt /Log=LogFiles/Log-$Date.log
Sleep 120

# Check if File(s) Exists After Download completes
$File = Get-ChildItem "SomePath\*.txt" | where {$_.LastWriteTime.Date -eq ($Date)}
$Checkfile = test-path $File

Get-Content Log-$Date.log

If ($Checkfile -eq $True)

{
Send-MailMessage -To "someone" -From "someone" -Subject "The File Has Downloaded" -SmtpServer "10.10.10.10"

}

else

{

}