Forum Discussion
NPleazy
Jul 29, 2021Copper Contributor
Saving a file to a folder: Access to the path is denied
I'm getting an error related to not having access to a path on my virtual AWS machine. My profile is administrator I deal with PHI so I redacted any evidence of where I work or the vendors that I...
RGijsbersRademakers
Aug 01, 2021Iron Contributor
NPleazy, the error message states that you don't have access to C:\Users\pbigateway\OneDrive.
This happens because your path contains spaces, you should place it between quotes so Powershell knows about the complete path. it would look like this. Take not of the quotes: '
Invoke-RestMethod 'https://web.*Redacted*.com/api/dataexport/download/*Redacted*' -Headers @{'*Redacted*'} >> 'C:\Users\pbigateway\OneDrive - *Redacted*\Documents\*Redacted*_Report_APIs\PBI_Dashboard\Daily/$(Get-Date -format "yyyy.MM.dd.HH.mm").csv'
And as farismalaeb already mentioned, the forward slash won't work. A filename cannot contain any slashes. So you should change the forward slash (/) to a backslash (\). The csv file will be downloaded to the Daily folder.
Grtz Ruud