Forum Discussion

HaroldvandeKamp's avatar
Aug 29, 2016
Solved

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...
  • Charles Willwerth's avatar
    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()

Resources