SOLVED

Get-PnPList : The remote server returned an error: (403) Forbidden

Iron Contributor

If I connect to the OneDrive site using "connect-pnponline" command and try to do the "Get-PnpList" then I get the "Get-PnPList : The remote server returned an error: (403) Forbidden" error.

 

But if I connect to SharePoint sites, then the "Get-PnpList" command works fine.

 

What can I do to get rid of this forbidden error?

 

$SiteURL = "https://xxxxxx-my.sharepoint.com/personal/xxxxxx"
$ListName= "Documents"

$List = Get-PnPList -Identity $ListName

2 Replies

Hi @ellan1537,

the "Get-PnPList : The remote server returned an error: (403) Forbidden" error typically points to a permission issue.

Here are the steps to troubleshoot the issue:

  1. Verify your credentials:
    Ensure that the provided URL and credentials are accurate. It's possible that you unintentionally used credentials from another tenant, leading to this error.
  2. Check access to the site: Confirm your access to the site by navigating to it directly. Even if you have Tenant Admin or SharePoint Online Administrator roles, explicit addition to the site may be required.
  3. Review site lock status:
    Check if the site is in a locked state.
  4. Consider network and device compliance:
    Ensure you are in your organization's network with a compliant device according to tenant conditional access policies.
  5. Credential type matters: When passing credentials, make sure they are of type "SharePointOnlineCredentials".

    Get-PnPList e on SharePoint 2019 will return this error "(403)Forbidden" - Microsoft Q&A

If you are using app permissions with a Registered App in Azure AD, ensure that the app has been granted all necessary SharePoint-related permissions.
authentication - PnP Powershell Sharepoint with app permissions: The remote server returned an error...

Please click Mark as Best Response & Like if my post helped you to solve your issue.
This will help others to find the correct solution easily. It also closes the item.


If the post was useful in other ways, please consider giving it Like.


Kindest regards,


Leon Pavesic
(LinkedIn)

best response confirmed by ellan1537 (Iron Contributor)
Solution
Although my account has full access to OneDrive and SharePoint sites, my account has been blocked from running Pnp Powershell for OneDrive. With the help of internal teams, my issue has been resolved.
1 best response

Accepted Solutions
best response confirmed by ellan1537 (Iron Contributor)
Solution
Although my account has full access to OneDrive and SharePoint sites, my account has been blocked from running Pnp Powershell for OneDrive. With the help of internal teams, my issue has been resolved.

View solution in original post