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 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.
And you need to update Page Properties or edit the file name, title, and its custom columns using PowerShell!
In this case, you can use the Update Page Properties PowerShell Script that does the following:
- Check if the SharePoint site exists or not.
- Check if the provided current file already exists or not.
- Also, it checks if the new file name does not already exist.
- After that, it checks if the file is checked out or not to start the update process.
- Finally, it updates the file name, title, and other custom columns as you need, then opens the modified file in the browser.
Download the full PowerShell Script from GitHub at SharePoint Administration PowerShell Scripts repo.
How to use Update Page Properties PowerShell Script?
- Download the PowerShell Script file from My GitHub.
- In your SharePoint Server, Open Windows PowerShell ISE as Administrator.
- From the file menu, open the downloaded file.
- 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)
- In this section, you can provide all custom fields that you need to update.
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!
- 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 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.
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.
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.
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.