Forum Discussion
Sharepoint 2013 and Powershell
Can you share the PoSh you're using today? I mean, this works:
wget https://sharepoint.example.com/sites/siteName/DocLibName/myFile.xlsx -UseDefaultCredentials:$true
I'm trying to download a file from our on-premise Sharepoint site. If I use the PS code below, the file downloads OK - either using the default creds (under my user account) or if I explicitly enter my creds using get-credential.
Invoke-WebRequest -uri $fromfile1 -outfile $tofile1 -UseDefaultCredential
Invoke-WebRequest -uri $fromfile1 -outfile $tofile1 -Credential (Get-Credential)
But I need to have this code run under the local system account. When I enter my creds using get-credential - the same as above - in a PS window running under local system, I get:
Invoke-WebRequest : 401 UNAUTHORIZED
- Feb 27, 2018In that case, it looks like you just don't have permission or your URL to the file is incorrect. You can use Fiddler to trace the web request. Otherwise your cmdlet is correct.
- DeletedFeb 27, 2018
I'm using the same credentials and the same source/destination in the powershell code that I'm running under Local System as the powershell code I'm running under my user creds. But the end result is not the same.
- Feb 27, 2018Well localsystem is a machine account so it's not going to have access to the resource. You cannot assign a computer account (MACHINENAME$) to a SharePoint resource, either.