Skip to content
Rishan Solutions
Rishan Solutions
  • PowerApps
  • SharePoint online
    • Uncategorized
    • Uncategorized
  • PowerAutomate
Rishan Solutions
Latest Posts
  • Agentic AI: The Dawn of Autonomous Intelligence Revolutionizing 2025 June 24, 2025
  • Recursive Queries in T-SQL May 7, 2025
  • Generating Test Data with CROSS JOIN May 7, 2025
  • Working with Hierarchical Data May 7, 2025
  • Using TRY_CAST vs CAST May 7, 2025
  • Dynamic SQL Execution with sp_executesql May 7, 2025

Checking External Sharing Settings on a Site using PnP PowerShell

Posted on March 18, 2025March 18, 2025 by Rishan Solutions

Loading

In SharePoint Online, external sharing settings determine how users can share content with external users (guests). Organizations need to ensure that external sharing settings align with security and compliance policies.

Using PnP PowerShell, you can quickly retrieve and verify external sharing settings for a SharePoint site to prevent unauthorized access and enforce governance policies.


Prerequisites

Before checking external sharing settings, ensure the following:

You have SharePoint Admin or Global Admin permissions.
You have PnP PowerShell installed.
You are connected to SharePoint Online.


Step 1: Install and Import PnP PowerShell

If you haven’t installed PnP PowerShell, install it using:

Install-Module -Name PnP.PowerShell -Scope CurrentUser -AllowClobber -Force

Then, import the module:

Import-Module PnP.PowerShell

Step 2: Connect to SharePoint Online

To check external sharing settings, first connect to the SharePoint Online Admin Center:

Connect-PnPOnline -Url "https://yourtenant-admin.sharepoint.com" -Interactive

Replace "yourtenant" with your actual tenant name.

For app-based authentication, use:

Connect-PnPOnline -Url "https://yourtenant-admin.sharepoint.com" -ClientId "Your-App-Client-ID" -Tenant "yourtenant.onmicrosoft.com" -CertificatePath "Path\To\Certificate.pfx"

Step 3: Check External Sharing Settings for a Specific Site

To check external sharing settings for a specific SharePoint site, use:

# Define site URL
$siteUrl = "https://yourtenant.sharepoint.com/sites/YourSite"

# Get site external sharing settings
$site = Get-PnPTenantSite -Url $siteUrl
$site | Select-Object Url, SharingCapability

🔹 Replace "YourSite" with your actual site name.
🔹 This command retrieves the external sharing settings for the site and displays:

  • URL → Site collection URL.
  • SharingCapability → The current external sharing setting.

Possible Values for SharingCapability:

ValueDescription
DisabledExternal sharing is completely turned off.
ExistingExternalUserSharingOnlyOnly existing external users can be invited.
ExternalUserSharingOnlyNew external users can be invited, but no anonymous links.
ExternalUserAndGuestSharingAnonymous sharing links and external users allowed.

Step 4: Check External Sharing Settings for All Sites

To check external sharing settings across all sites:

# Get all site collections
$sites = Get-PnPTenantSite

# Select relevant details
$sites | Select-Object Url, Title, SharingCapability | Format-Table -AutoSize

🔹 This lists the sharing settings for all site collections in a structured table.

To export the results to a CSV file, use:

$sites | Select-Object Url, Title, SharingCapability | Export-Csv -Path "C:\ExternalSharingSettings.csv" -NoTypeInformation

The CSV file will contain a report of all site collections and their external sharing settings.


Step 5: Verify External Sharing Settings in SharePoint Admin Center

If needed, verify the external sharing settings through the SharePoint Admin Center:

1️⃣ Navigate to SharePoint Admin Center → https://yourtenant-admin.sharepoint.com
2️⃣ Click on Active sites
3️⃣ Select a site and click Policies > Sharing
4️⃣ Confirm the external sharing level


Step 6: Adjust External Sharing Settings (Optional)

If external sharing is too restrictive or too open, you can modify it using:

Set-PnPTenantSite -Url "https://yourtenant.sharepoint.com/sites/YourSite" -SharingCapability ExternalUserSharingOnly

This command changes the external sharing setting to allow only existing external users.

🔹 Other possible values:

Set-PnPTenantSite -Url "https://yourtenant.sharepoint.com/sites/YourSite" -SharingCapability Disabled

Disables external sharing completely.

Set-PnPTenantSite -Url "https://yourtenant.sharepoint.com/sites/YourSite" -SharingCapability ExternalUserAndGuestSharing

🔹 Allows both external users and anonymous links.


Step 7: Disconnect the PowerShell Session

After checking or modifying settings, securely disconnect the session:

Disconnect-PnPOnline

This prevents unauthorized access.


Common Errors & Troubleshooting

ErrorCauseSolution
Get-PnPTenantSite : The term is not recognizedYou are not connected to the SharePoint Admin CenterUse -Url "https://yourtenant-admin.sharepoint.com" in Connect-PnPOnline
Access DeniedInsufficient permissionsEnsure you are a SharePoint Admin or Global Admin
Cannot connect to SharePoint OnlineAuthentication issueUse -Interactive login or App-based authentication
Set-PnPTenantSite : Parameter SharingCapability cannot be setYou may be modifying a Hub site or Teams-connected siteUse Admin Center UI for those sites
Posted Under PNP PowerShellexternal sharing Get-PnPTenantSite Microsoft 365 PNP PowerShell Set-PnPTenantSite SharePoint administration SharePoint online SharePoint Security SharingCapability

Post navigation

Exporting Site Collection Details to a CSV File using PnP PowerShell
Bulk Updating Site Collection Properties using PnP PowerShell

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • Agentic AI: The Dawn of Autonomous Intelligence Revolutionizing 2025
  • Recursive Queries in T-SQL
  • Generating Test Data with CROSS JOIN
  • Working with Hierarchical Data
  • Using TRY_CAST vs CAST

Recent Comments

  1. Michael Francis on Search , Filter and Lookup in power apps
  2. A WordPress Commenter on Hello world!

Archives

  • June 2025
  • May 2025
  • April 2025
  • March 2025
  • February 2025
  • March 2024
  • November 2023
  • October 2023
  • September 2023
  • August 2023
  • June 2023
  • May 2023
  • April 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • January 2022

Categories

  • Active Directory
  • AI
  • AngularJS
  • Blockchain
  • Button
  • Buttons
  • Choice Column
  • Cloud
  • Cloud Computing
  • Data Science
  • Distribution List
  • DotNet
  • Dynamics365
  • Excel Desktop
  • Extended Reality (XR) – AR, VR, MR
  • Gallery
  • Icons
  • IoT
  • Java
  • Java Script
  • jQuery
  • Microsoft Teams
  • ML
  • MS Excel
  • MS Office 365
  • MS Word
  • Office 365
  • Outlook
  • PDF File
  • PNP PowerShell
  • Power BI
  • Power Pages
  • Power Platform
  • Power Virtual Agent
  • PowerApps
  • PowerAutomate
  • PowerPoint Desktop
  • PVA
  • Python
  • Quantum Computing
  • Radio button
  • ReactJS
  • Security Groups
  • SharePoint Document library
  • SharePoint online
  • SharePoint onpremise
  • SQL
  • SQL Server
  • Template
  • Uncategorized
  • Variable
  • Visio
  • Visual Studio code
  • Windows
© Rishan Solutions 2025 | Designed by PixaHive.com.
  • Rishan Solutions