Forum Discussion
Aug 29, 2016
Rename a document stored inside a SharePoint document library using Office Dev PnP
How to rename a document/file stored inside a documentlibrary using Office Dev PnP? I haven't found a cmdlet for it. Specifically I want to rename the OneNote Notebook called "Team Site Notebo...
- Aug 30, 2016
I might be misinterpreting the question, but does this help?
"MoveTo" can be used to rename files.
Connect-SPOnline -url [yoururl] $ctx = Get-SPOContext $web = Get-SPOWeb $file = $web.GetFileByServerRelativeUrl("[your file url]") $file.MoveTo("[your NEW server-relative url]", 'Overwrite') $ctx.ExecuteQuery()
Andreas Lemarcq
Jul 10, 2025Brass Contributor
Charles Willwerth​ and HaroldvandeKamp​
Thanks for the solution.
It allowed me to work this out in PnP PowerShell.
$web = Get-PnPWeb
$folder = $web.GetFolderByServerRelativeUrl("/sites/SITEURL/SiteAssets/Team Site Notebook")
$folder.MoveTo("/sites/SITEURL/SiteAssets/MySpecificSiteNotebookName")
$web.Update()
Invoke-PnPQuery