"System Error. Code: 395. Access to the cloud file is denied"
Hello again. I have a download script running on PowerShell, and encountered a bizarre error I've never seen before. The downloads GO to a Microsoft SharePoint folder that I have synced to my local C drive, and I can access it and open it with no problem locally and remotely. The file in question was downloaded, but why would it say it can't OPEN the file and then terminate the script?
Here is my portion of the script that ran it:
Part of the log file in question:
Why would it need to OPEN the file and throw an access error only for that one file? It retrieved several other .csv files from the same location. Seems like it's a terminating error once it hits that file. The file follows a normal naming convention just like the others. Any ideas? Could it be an error with the
(Had to redact some info)"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"
Here is my portion of the script that ran it:
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")
?