How to Troubleshoot SharePoint Server 2019 PowerShell Script Errors
Question details
The user needs to diagnose and resolve errors in SharePoint Server 2019 PowerShell scripts, including access-denied messages, object-not-found results, and skipped site collections.

- Product
- SharePoint Server 2019
- Device & OS
- not provided
- Scenario
- Running administrative or automation PowerShell scripts via the SharePoint Management Shell.
- Observed behavior
- Scripts fail to execute properly, returning access-denied errors, reporting objects not found, or skipping specific site collections entirely.
Ensure you have access to SharePoint Central Administration and are launching the SharePoint Management Shell with administrative privileges.
Grant Required Script Account Permissions
Farm administrator status alone may not provide all necessary permissions. You must grant specific access via the Web Application User Policy.
Many script failures occur because the executing account lacks explicit permissions on the target site collections, even if it is a farm administrator account.
Open SharePoint Central Administration and navigate to the 'Security' section.
Click on 'Configure Web Application User Policy' and select the target web application.
Add the account used to run the PowerShell script and grant it 'Full Control' where appropriate.
If necessary, navigate to the specific affected sites and manually add the script account as a Site Collection Administrator.

Inspect Site Collections and Rerun Scripts
Verify the status of the affected site collections to ensure they are not locked or inaccessible, and run the script in the correct environment.
Manage Your SharePoint Documents Seamlessly with WPS Office
While resolving server-side PowerShell script errors requires Microsoft administrative tools, WPS Office is an excellent, free alternative for creating, editing, and managing the actual documents stored within your SharePoint environment. It offers high compatibility and a lightweight design.
- 1. Download the Installer: Visit the official WPS Office website and download the free installer for your operating system.
- 2. Install WPS Office: Run the installer and follow the quick on-screen instructions to set up the suite on your device.
- 3. Open SharePoint Files: Download your documents from SharePoint and open them directly in WPS Writer, Spreadsheet, or Presentation to start editing.

Frequently Asked Questions
Why does my script return 'access denied' if I am a farm administrator?
Farm administrator status grants access to Central Administration but does not automatically grant access to the content within all site collections. You often need to add the account to the Web Application User Policy with Full Control.
How do I check if a SharePoint site collection is locked?
You can check the lock status by running the Get-SPSite cmdlet in the SharePoint Management Shell and inspecting the 'ReadOnly' or 'LockIssue' properties of the site collection object.
Can I use standard Windows PowerShell instead of the SharePoint Management Shell?
While possible if you manually load the Microsoft.SharePoint.PowerShell snap-in, it is highly recommended to use the SharePoint Management Shell as it automatically loads the required cmdlets and configures the correct execution environment.




