Nevermind, issues seemed to have solved themselves for now after several OneDrive re-boots and global Autosave on Office products set to 'Off'
- abd1111
"2024-11-13 18:43:57 - Exception calling "Check" with "0" argument(s): "Can't open file 'C:\Users\UserName\CoName\HealthCare - Eligibility Files\CoName1\0- Initial Eligibility\11.10.24 CoName2 Elig - xx.csv'.
System Error. Code: 395.
Access to the cloud file is denied"
try
{
Add-Type -Path "C:\Program Files (x86)\WinSCP\WinSCPnet.dll"
$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
Protocol = [WinSCP.Protocol]::Sftp
HostName = "x"
UserName = "x"
Password = "x"
SshHostKeyFingerprint = "x"
}
$session = New-Object WinSCP.Session
$remotePath = "/Co.Name/Carrier/0 - Initial Eligibility Upload to x/"
$localPath = "C:\Users\UserName\Co.Name1\HealthCare Files\Co.Name\0- Initial Eligibility\"
# Connect
$session.Open($sessionOptions)
$session.Timeout = New-TimeSpan -Seconds 1000
# Masking
$transferOptions = New-Object WinSCP.TransferOptions
$transferOptions.FileMask = "*.*"
# Download files
$transferOptions.AddRawSettings("ExcludeEmptyDirectories", "1")
$transferOptions.AddRawSettings("NewerOnly", "1")
$session.GetFiles($remotePath, $localPath, $False, $transferOptions).Check()
}
catch
{
Write-Host "$_"
$ErrorMessage = $_.Exception.Message
$TimeStamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
$LogMessage = "$TimeStamp - $ErrorMessage"
Add-Content -Path "C:\Users\UserName\Documents\FTP Project LOGS\ErrorFileLog.txt" -Value $LogMessage
}
finally
{
# Disconnect, clean up
$session.Dispose()
}
< 2024-11-14 18:42:58.099 Type: SSH_FXP_STATUS, Size: 17, Number: 4450820
. 2024-11-14 18:42:58.099 Discarding reserved response
< 2024-11-14 18:42:58.225 Type: SSH_FXP_HANDLE, Size: 45, Number: 4451075
> 2024-11-14 18:42:58.225 Type: SSH_FXP_FSTAT, Size: 45, Number: 4451336
< 2024-11-14 18:42:58.282 Type: SSH_FXP_ATTRS, Size: 29, Number: 4451336
* 2024-11-14 18:42:58.282 (EOSError) System Error. Code: 395.
* 2024-11-14 18:42:58.282 Access to the cloud file is denied
. 2024-11-14 18:42:58.282 Asking user:
. 2024-11-14 18:42:58.282 Can't open file 'C:\Users\UserName\CoName\HealthCare - Eligibility Files\CoName1\0- Initial Eligibility\11.10.24 CoName2 Elig - xx.csv'. ("System Error. Code: 395.
. 2024-11-14 18:42:58.282 Access to the cloud file is denied")
< 2024-11-14 18:42:58.282 Script: Can't open file 'C:\Users\UserName\CoName\HealthCare - Eligibility Files\CoName1\0- Initial Eligibility\11.10.24 CoName2 Elig - xx.csv'.
< 2024-11-14 18:42:58.282 Script: System Error. Code: 395.
< 2024-11-14 18:42:58.282 Access to the cloud file is denied
. 2024-11-14 18:42:58.282 Answer: Abort
> 2024-11-14 18:42:58.282 Type: SSH_FXP_CLOSE, Size: 45, Number: 4451588
* 2024-11-14 18:42:58.282 (ESkipFile) Can't open file 'C:\Users\UserName\CoName\HealthCare - Eligibility Files\CoName1\0- Initial Eligibility\11.10.24 CoName2 Elig - xx.csv'.
* 2024-11-14 18:42:58.282 System Error. Code: 395.
* 2024-11-14 18:42:58.282 Access to the cloud file is denied
. 2024-11-14 18:42:58.282 Script: Failed
> 2024-11-14 18:42:58.968 Script: exit
. 2024-11-14 18:42:58.968 Script: Exit code: 1
. 2024-11-14 18:42:58.968 Closing connection.
. 2024-11-14 18:42:58.968 Sending special code: 1
. 2024-11-14 18:42:59.111 Session sent command exit status 0
. 2024-11-14 18:42:59.111 Main session channel closed
. 2024-11-14 18:42:59.111 All channels closed[/quote]
$transferOptions.AddRawSettings("NewerOnly", "1")
?