Forum Discussion

ellan1537's avatar
ellan1537
Iron Contributor
Dec 13, 2023
Solved

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

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

  • ellan1537's avatar
    ellan1537
    Dec 14, 2023
    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.

2 Replies

  • LeonPavesic's avatar
    LeonPavesic
    Silver Contributor

    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: (403) Forbidden - Stack Overflow

    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)

    • ellan1537's avatar
      ellan1537
      Iron Contributor
      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.

Resources