无App Catalog站点权限时,在SharePoint团队站点添加PnP Modern Script Editor应用的替代方案咨询
Great question! Let's break down your scenario first: you're a site owner/admin for a SharePoint Team Site, don't have access to the App Catalog or tenant-level SharePoint admin rights, and need to add the PnP Modern Script Editor without going through the App Catalog. Here are your viable alternatives:
1. Directly Upload the PnP Script Editor App Package to Your Site
This works if your site allows custom app deployments (we'll cover how to check that below):
- First, get the official
.apppackage for the PnP Modern Script Editor from its official release source. - Navigate to your Team Site → Click the settings gear → Site contents → Click New → App.
- On the "Your Apps" page, select the Upload App button in the top-right corner.
- Choose the downloaded
.apppackage, follow the prompts to upload and install it to your site.
Check/Adjust Custom Script Permissions
This method requires your site's custom script restriction to be disabled. To verify and adjust this (if you have the necessary permissions):
- Use PnP PowerShell to check the current setting:
Connect-PnPOnline -Url "https://yourtenant.sharepoint.com/sites/yoursite" -Interactive Get-PnPTenantSite -Url "https://yourtenant.sharepoint.com/sites/yoursite" | Select-Object DenyAddAndCustomizePages - If the output is
False, you're good to go. If it'sTrue, you'll need to disable this restriction. Note: Changing this setting typically requires tenant-level admin rights—if you don't have that, this method won't work, and you'll need to jump to option 3.
2. Deploy the App via PnP PowerShell
If you prefer a command-line approach, you can use PnP PowerShell to upload and install the app directly to your site:
- First, connect to your site:
Connect-PnPOnline -Url "https://yourtenant.sharepoint.com/sites/yoursite" -Interactive - Then upload and install the app package:
Add-PnPApp -Path "C:\Path\To\pnp-modern-script-editor.app" -Scope Site -SkipFeatureDeployment - Same as option 1, this requires the
DenyAddAndCustomizePagessetting to beFalse.
3. Build a Custom SPFx Web Part (No App Catalog Needed)
If you can't disable the custom script restriction, building a simple SharePoint Framework (SPFx) Web Part is your best bet. This uses side-loading, which doesn't require App Catalog access:
- Set up your SPFx development environment (install Node.js, Yeoman SharePoint Generator, and gulp).
- Create a new SPFx Web Part that mimics the PnP Script Editor's core functionality: add a text input field for HTML/JS code, then render that code in the web part.
- Enable side-loading on your site: Go to Site Settings → Site Collection Features → Activate the SharePoint Framework Developer Feature.
- Run
gulp serve --nobrowserto start the local development server, then add the side-loaded web part to your site pages.
This method lets you add script editing functionality without touching the App Catalog or tenant-level settings.
内容的提问来源于stack exchange,提问作者thedeepponkiya

