SharePoint 2019: Update Page Properties using PowerShell

Update SharePoint Page Properties using PowerShell

In this post, we’re going to introduce a simple PowerShell script that would help you to update Page Properties or File Properties and their Custom Fields in SharePoint 2019 using PowerShell.

Update Page Properties using PowerShell in SharePoint 2019
Update Page Properties using PowerShell in SharePoint 2019

Update Page Properties using PowerShell

In some cases, you may need to update Page Properties in a Pages Library inside a Publishing Site using PowerShell, Also you may need to edit the file name, title, and its custom columns in a Document or Image Library using PowerShell.

In our example, consider you have a Page Library or Document Library that holds files.

Update file Properties using PowerShell in SharePoint 2019

And you need to update Page Properties or edit the file name, title, and its custom columns using PowerShell!

Edit file Properties using PowerShell in SharePoint 2019
Edit file Properties using PowerShell in SharePoint 2019

In this case, you can use the Update Page Properties PowerShell Script that does the following:

  1. Check if the SharePoint site exists or not.
  2. Check if the provided current file already exists or not.
  3. Also, it checks if the new file name does not already exist.
  4. After that, it checks if the file is checked out or not to start the update process.
  5. Finally, it updates the file name, title, and other custom columns as you need, then opens the modified file in the browser.
Update file Properties PowerShell in SharePoint 2019

Download the full PowerShell Script from GitHub at SharePoint Administration PowerShell Scripts repo.

How to use Update Page Properties PowerShell Script?

  1. Download the PowerShell Script file from My GitHub.
  2. In your SharePoint Server, Open Windows PowerShell ISE as Administrator.
  3. From the file menu, open the downloaded file.
  4. Provide the following values based on your needs.
    • $siteURL (the site URL)
    • $CurrentPageURL (Add the full page or file path that you need to update its properties)
    • $NewPageURL (Add the full page or file path with the new name, and this value is required to perform check-in after renaming the file name)
    • $NewpageName (Add the name of the new page)
    • $NewpageTitle (Add the title of the new page)
powershell script sharepoint 2019 variables
  1. In this section, you can provide all custom fields that you need to update.
PowerShell script sharepoint 2019 custom fields

Note: This PowerShell script would help you update page Name and Title and other custome fields. however, you can’t update the readonly fields like Created and CreatedBy fields. It’s by design!

  1. Once you provided the required values, click on F5 to run your script.

PowerShell Script Output

Below are the possible result when you run the Update Page Properties PowerShell Script

Incorrect Site URL

In case, you have provided an incorrect Site URL, you will get an error message that tells you the provided site URL does not exist, and you have to set the Site URL correctly to proceed.

incorrect sharepoint site url
Incorrect File URL

In case, you have provided an incorrect Page or File URL, you will get an error message that tells you the provided Page URL does not exist, and you have to set the Page or File URL correctly to proceed.

check if the file not found in sharepoint
The new file name already exists

In case, you have provided a new file name that already exists, you will get an error message that tells you the specified name already exists, and you have to provide another Page name to proceed.

check if the file name is already in use in SharePoint powershell
Best case Result

In case, you have provided all required values correctly, the Page will be updated properly and the page will be opened in the default browser with the new updated properties.

rename file in sharepoint 2019 using powershell

Conclusion

You can easily update Page Properties in the browser, however, you may need to do the same function in PowerShell. So, we have provided this simple PowerShell Script that would help you to rename a SharePoint file or update Page Properties using PowerShell in SharePoint Server.

Download

Follow the SharePoint Administration repo on GitHub to get all new PowerShell scripts that help you to manage SharePoint Server, and download the “Update Page Properties” PowerShell script to can rename or update your file properties.

Applies To
  • SharePoint 2019.
  • SharePoint 2016.
  • SharePoint 2013.
See Also

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top