Answered by:
AccessDenied exception when using New-WebServiceProxy

Question
-
Hello all,
I want to use SharePoint Web Services using powershell. But I have a problem, in this script
$uri = SharePoint/_vti_bin/Lists.asmx
$service = New-WebServiceProxy -Uri $uri
But when i call some methods like $service.getList('MyList'), this error, appear:
Server was unable to process request. ---> Access is denied.
My work mates told me that it could be because SharePoint has ADFS authentification.
I can generate automatic the adfs token but i dont know how to use it
I have read this pages but doesn't help my issue help:https://social.msdn.microsoft.com/Forums/en-US/5eab2116-7d7c-4bf3-bfa1-48bd8992dded/access-is-denied-exception-from-hresult-0x80070005-eaccessdenied-accessing-the-sharepoint?forum=sharepointcustomizationlegacy
https://social.technet.microsoft.com/Forums/en-US/dfd54738-d550-48a2-8e68-09da4cebdc3d/access-denied-when-calling-getlistitems-webservice?forum=fastsharepoint
Regards
Marquez96.Wednesday, September 20, 2017 3:09 PM
Answers
-
Hi,
I ask the same question in the SharePoint's forum, and gives me the answer.
PnP Core AuthManager. provides a helper class for this requirement, so you could use it in PowerShell or custom
PnP powershell: https://github.com/SharePoint/PnP-PowerShell
Regards,
Marquez96
Tuesday, October 24, 2017 7:16 AM
All replies
-
You have to have permission on the site and list.
\_(ツ)_/
Wednesday, September 20, 2017 3:23 PM -
The links you posted are not valid for SP 2016 or SP Online.
\_(ツ)_/
Wednesday, September 20, 2017 3:26 PM -
Hello,
I have the correct permission on the site and list. I can access in a browser with this user. I tried to use credentials in New-WebServiceProxy -Uri $uri -Credetial $cred but didn't work to.
The SharePoint version is SP 2013.
Regards
Thursday, September 21, 2017 1:01 PM -
Then you are using the wrong URI for the list. Post in SP forum for more specific assistance.
"Access denied" is not a script related issue except when you are using an incorrect URI or when the permissions are not set to allow programmatic access.
\_(ツ)_/
- Edited by jrv Thursday, September 21, 2017 1:05 PM
Thursday, September 21, 2017 1:04 PM -
Hi,
I ask the same question in the SharePoint's forum, and gives me the answer.
PnP Core AuthManager. provides a helper class for this requirement, so you could use it in PowerShell or custom
PnP powershell: https://github.com/SharePoint/PnP-PowerShell
Regards,
Marquez96
Tuesday, October 24, 2017 7:16 AM