I am using Powershell
DownloadFile(,) command for reading a .csv file from a document library in SharePoint 2013 site. When i ran the code on my DEV environment, it ran properly. The DEV environment is using
http://. But , when I run this code on TEST environment i get
403 Forbidden error. The site(TEST environment) is running over
I am using below code ,
$FilePath = "https://ServerName/sites/SiteName/MyDocumentLibrary/MyCSVFile.csv" $localPath = "C:\temp\test.csv" $wc = New-Object System.Net.Webclient $wc.DownloadFile($FilePath, $localPath) $list = Import-Csv $localPath
The error says,
Exception calling "DownloadFile" with "2" argument(s): "The remote server returned an error: (403) Forbidden." At D:\Amit\UpdateUserInformationList.ps1:39 char:1
I have gone through various articles which talks about passing credentials with the
Webclient($wc) object. But, with no luck. Still getting same error.
I am still unaware, when/why does Powershell throws this error ? What is the root cause of this error?
Any help will be greatly appreciated.