You've published your SharePoint pages. The content is live. But search results are coming up empty. Sound familiar?
If your SharePoint site has Content Approval enabled on the Site Pages library, and your pages are organised into folders, there's a gotcha that catches almost everyone — and it's not obvious at all.
Quick Check
If your Site Pages library uses Content Approval and your pages are organised into folders, check whether the folder itself has a Pending approval status. That's likely your problem.
The Problem
When Content Approval is enabled on a Site Pages library, SharePoint doesn't just require individual pages to be approved. Folders are subject to content approval too. And here's the critical part — if a folder has a status of Pending, pages inside it may not appear in search, even if those individual pages are approved.
You can approve every page in the folder manually. You can republish them. Search may still return nothing. The folder itself is the blocker.
Why This Is So Hard to Spot
The folder approval status isn't surfaced anywhere obviously in the SharePoint UI. When you're looking at your Site Pages library, folders don't show a clear Pending or Approved badge in the default view. You might notice the status column if you've added it to the view, but even then it's easy to miss — especially when you're focused on the pages themselves rather than the folder structure.
The pages look published. The pages look approved. But search returns nothing.
The Manual Fix — Except It Doesn't Exist
Here's where it gets really frustrating. Unlike individual pages, there is no UI option to approve a folder through the SharePoint interface.
With a page, you can open it, go to the page details, and change the approval status. With a folder, that option simply isn't there. Microsoft hasn't exposed folder approval in the standard interface — which means if you've hit this problem, clicking around in SharePoint looking for an approve button on the folder is going to get you nowhere.
In most cases, the only practical way to approve a folder is programmatically.
The Fix — PnP PowerShell
The solution is to update the folder's _ModerationStatus field directly using PnP PowerShell. This is the internal field SharePoint uses to track content approval status — setting it to 0 marks the item as Approved.
This is exactly what the Update-Pages-Approval-Status-In-Folder script does. The script:
- Connects to your SharePoint site
- Scans the entire Site Pages library for folders with a Pending status — you don't need to know which folders are affected, it finds them automatically
- Updates
_ModerationStatusto Approved on any pending folders - Logs all results to a CSV file for auditing
Once the folder status is updated, pages inside it should start appearing in search results after the next crawl, which can take anywhere from minutes to several hours depending on your tenant configuration.
Step by Step
-
Identify the problem
Add the Approval Status column to your Site Pages library view. Check whether any folders show a status of Pending or Draft rather than Approved. -
Run the script
Update the configuration variables at the top of the script:$SiteUrl = "https://yourtenant.sharepoint.com/sites/yoursite" $LibraryName = "Site Pages" $ApprovalStatus = 0 # 0 = ApprovedThe script will scan all folders automatically and report what it finds before making any changes.
-
Verify
After running, check the Approval Status column in the library — folders should now show Approved. Trigger a manual search reindex if needed, or wait for the next scheduled crawl. Search Reindex: users can go to Site Settings > Search and Offline Availability > Reindex site to speed things up.
Prevention
If you're setting up Content Approval on a Site Pages library from scratch, approve any existing folder structure before publishing pages into it. It's much easier to handle upfront than diagnosing why search isn't working after the fact.
This can also apply to other document libraries with Content Approval enabled — if you're using approval workflows on libraries with a folder structure, the same issue may occur.
Summary
| Issue | Likely Cause | Fix |
|---|---|---|
| Pages not appearing in search | Folder approval still Pending | Approve folder via PnP PowerShell |
| Can't approve folder in UI | No UI support for folder approval | Use script to update _ModerationStatus |
| Pages approved but still hidden | Folder status overriding page status | Approve the folder |
If you're managing a SharePoint intranet with Content Approval and a structured folder hierarchy in Site Pages, this is one of those issues worth knowing about before it bites you in production.
Troubleshooting & Edge Cases
If you've run the script and are still seeing issues, check these three common "stuck" scenarios:
Items Checked Out: PowerShell cannot update the moderation status of a folder or page if a user has it checked out. Ensure all items are checked in before running the script.
Version Transitions: If your library uses Major/Minor (Draft) versioning, a folder can occasionally get "stuck" in a draft state if the original creator's permissions have changed or their account is deactivated.
Permission Levels: To force an update on the _ModerationStatus field, ensure you are running the PnP PowerShell script with Site Collection Administrator rights. Standard "Full Control" can sometimes be blocked by specific library-level item security.