POWERSHELL / SHAREPOINT
ProAdvancedChanges dataMedium

Bulk update SharePoint site sharing settings from CSV

Validates, previews and optionally applies supported SharePoint site sharing-capability changes from CSV with tenant-policy preflight and read-back verification.

Pro generation after license validation · Review before running · No tenant access

What this PowerShell script does

Validates, previews and optionally applies supported SharePoint site sharing-capability changes from CSV with tenant-policy preflight and read-back verification.

Requirements

  • SharePoint admin URL - Tenant administration URL used to read and update site sharing capability.
  • Entra app client ID - Your PnP app client ID. Leave empty only when a PnP default client ID is already configured.
  • Input CSV path - CSV schema: SiteUrl;SharingCapability using one supported value.
  • Execution mode - Preview is the safe default. Apply performs real changes only after all rows pass preflight.
  • Apply confirmation - When Execution mode is Apply, enter APPLY exactly. ShouldProcess confirmation is still used during execution.
  • Result CSV path - Use a new absolute Windows CSV path. A result file is written for preview and apply modes.

Environment

  • Module: PnP.PowerShell
  • Runtime: PowerShell 7.4+
  • Authentication: Interactive PnP with your own client ID/default
  • Permissions: SharePoint Administrator plus the least-privileged SharePoint write permission set required by Set-PnPTenantSite.
  • Risk: Medium
Review before you runRun Preview first. Apply changes only after reviewing every planned row and target.
OPS / WORKSPACE

Ready to generate

Configure Bulk update SharePoint site sharing settings from CSV in the Builder, review the generated PowerShell and run it in your own environment.

When to use this template

Use this controlled bulk workflow to change only SharePoint site SharingCapability values from a validated CSV.

Important limitations

PowerShell and PnP requirements

Current PnP.PowerShell releases require PowerShell 7.4 or later. Interactive authentication requires your own Entra application/client ID, or a configured PnP default client ID. This script changes SharePoint configuration. Preview is the default and real changes require explicit Apply confirmation plus ShouldProcess approval.

Opselith does not connect to your tenant or execute the script on your behalf. No tenant connection is required. When you generate a Pro script, only the configuration values needed for that template are sent to Opselith after license validation. Template source remains server-side.

Generate the script

  1. Open this template in the PowerShell Builder.
  2. Enter the required scope, safety and output values.
  3. Generate and review the PowerShell before running it in your own environment.
Generate Bulk update SharePoint site sharing settings from CSV →
OPS / SCRIPT DETAILS

Script details

Validates, previews and optionally applies supported SharePoint site sharing-capability changes from CSV with tenant-policy preflight and read-back verification. Review these details before generating or running the script.

sharepointsharingbulkcsvexternal-sharingautomation

What it works with

Module: PnP.PowerShell

Context: PowerShell 7.4+ · SharePoint Online · PnP.PowerShell

Compatibility: PowerShell 7.4+ is required by current PnP.PowerShell releases.

Permissions and impact

Permissions: AllSites.Manage · SharePoint Administrator

Risk: Medium

Execution impact: Changes data. Preview/WhatIf is the default. Apply mode requires a fully valid CSV, literal APPLY confirmation, ShouldProcess approval and post-change verification.

Parameters

  • SharePoint admin URL - Tenant administration URL used to read and update site sharing capability. (Required)
  • Entra app client ID - Your PnP app client ID. Leave empty only when a PnP default client ID is already configured. (Optional)
  • Input CSV path - CSV schema: SiteUrl;SharingCapability using one supported value. (Required)
  • Execution mode - Preview is the safe default. Apply performs real changes only after all rows pass preflight. (Required)
  • Apply confirmation - When Execution mode is Apply, enter APPLY exactly. ShouldProcess confirmation is still used during execution. (Conditional)
  • Result CSV path - Use a new absolute Windows CSV path. A result file is written for preview and apply modes. (Required)

Output

Output: CSV result with InputRow, SiteUrl, RequestedSharingCapability, PreviousSharingCapability, Preview, Changed, VerifiedCapability, Result and Error.

This template is part of the Pro library. The full Pro script is generated by Opselith after server-side license validation; only the configuration values needed by this template are sent for generation. No tenant connection is required. When you generate a Pro script, only the configuration values needed for that template are sent to Opselith after license validation.

Example use

Validates, previews and optionally applies supported SharePoint site sharing-capability changes from CSV with tenant-policy preflight and read-back verification.

Enter the required values in the Builder, review the generated script and confirm the output before running it.

Before you run: Run Preview first and confirm that every requested sharing level is permitted by tenant policy. Apply only after reviewing the full result plan.

Opselith quality checks

  • Included in the current Opselith PowerShell quality suite
  • Strict sharing-capability allowlist
  • Full CSV validation before any write
  • Duplicate site rows rejected
  • Tenant-policy ceiling checked
  • Preview/WhatIf default
  • Literal APPLY gate for real changes
  • SupportsShouldProcess with no Confirm suppression
  • No automatic write retries
  • Read-back verification