Take control of files created on SharePoint that are not published

David RamalhoMicrosoft 3654 years ago36 Views

Did you know that if you’re a SharePoint Site collection owner you cannot see all the pages created? A few days ago, I notice that I should have a certain number of pages on the Site Pages library (80 or something) but only a few appear for my user. You can verify how many files you have on the particular library on the Site contents of your site.

This happens because the page was created but nothing was been done with the page. Let’s give some example of how this can happen. You create a page on SharePoint but before adding any text or anything like that you just close the browser or navigate somewhere else. SharePoint will create a page with a random name that is saved for your user. This page will only be visible to your user, therefore, all the SharePoint Site collection owners will not see this file and this will create unnecessary information.

You can takeover this files following this steps

  1. Go to Library Settings of Site Pages
  2. Under Permissions and Management select Manage files which have no checked in version
  3. Select the files you want to have control and click on Take Ownership of Selection

The script below allows you to take control of the same files using PowerShell rather than UI. In case that you are doing some more actions on the site via PowerShell.

$library = "Site Pages"
$siteUrl = "https://contoso.sharepoint.com/sites/demosite"

Connect-PnPOnline -Url $siteUrl -UseWebLogin
$context = Get-PnPContext
$list = Get-PnPList -Identity $library

# Load the list
$context.Load($list)
Invoke-PnPQuery

# Load the checked out files
$checkedOutFiles = $list.GetCheckedOutFiles()
$context.Load($checkedOutFiles)
Invoke-PnPQuery

foreach ($file in $checkedOutFiles) {
    #Takeover the file
    Write-Host ("{0} File TakeOver" -f $file.ServerRelativePath.DecodedUrl) 
    $file.TakeOverCheckOut()
    Set-PnPFileCheckedIn -Url $file.ServerRelativePath.DecodedUrl
}

The post Take control of files created on SharePoint that are not published appeared first on SharePoint Tricks.

Original Post https://sharepoint-tricks.com/take-control-of-files-created-that-are-not-published-sharepoint/

0 Votes: 0 Upvotes, 0 Downvotes (0 Points)

Leave a reply

Join Us
  • X Network2.1K
  • LinkedIn3.8k
  • Bluesky0.5K
Support The Site
Events
March 2025
MTWTFSS
      1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31       
« Feb   Apr »
Follow
Sign In/Sign Up Sidebar Search
Popular Now
Loading

Signing-in 3 seconds...

Signing-up 3 seconds...