I am using the PnP PowerShell script Convert-WikiAndWebPartPages.ps1 (with the switch 'Modern page takes source page name' set to true), from Transforming to modern site pages using PowerShell, to convert site pages to modern pages.

But I am running into an issue with the migrated wiki pages. The pages contain links to the other pages, but after the conversion the links in the modern pages are pointing to Previous_xxx.aspx.

So after the conversion to modern pages all links need to be fixed to the original source page name (and I would like to keep the page creation/modification info).

Which PnP PowerShell commands can I use to correct the links?

  • How do you point to another page in the wikipage? Do you use ‘a’ element?
    – Amos
    Oct 19, 2020 at 9:28
  • Yes, but it is wiki pages so the user just enclose the word to link in brackets []. But if I check View source in the original files it is like: <a class="ms-wikilink" href="/sites/AAA/wiki/Wiki%20Pages/Test%20Information.aspx"> . And in the converted files it is like: \u003ca class=\\\"ms-missinglink\\\" href=\\\"/sites/AAA/SitePages/Previous_Test%20Information.aspx\\\"\u003e
    – Gunilla
    Oct 19, 2020 at 11:48

2 Answers 2


With the switch -TakeSourcePageName:$true I kept getting faulty links inside the migrated pages (pointing to Previous_xxx.aspx.), and I do not know how to correct that with PnP. This issue with -TakeSourcePageName:$true was very reproducible, even after I changed the locale.

So, as a workaround, I used -TakeSourcePageName:$false, which did not have the issue with faulty links, but created files named Migrated_*.aspx, which I did not want. I wrote the following script to rename them to their original names. (I do not need any backup of the old files, since I could just get new files with ShareGate from my old SharePoint on-prem site if I wanted to migrate them again).

This is the renaming script (which could probably be written as a one-liner..):

    $pages = Get-PnPListItem -List sitepages -PageSize 500 | Where {$_["FileLeafRef"] -like "Migrated_*.aspx"}
    Write-Host "Pages are fetched, let's start the renaming..." -ForegroundColor Green
    Foreach($page in $pages){
        $newpage = $page["FileLeafRef"] -replace ‘Migrated_’
        Rename-PnPFile -ServerRelativeUrl $page["FileRef"] -TargetFileName $newpage -OverwriteIfAlreadyExists -Force

    Write-Host "Renaming done!" -ForegroundColor Green```

  • Unfortunately I do not get to keep the page creation/modification info this way.
    – Gunilla
    Oct 27, 2020 at 13:40

I can not reproduce your issue with this cmdlet ConvertTo-PnPClientSidePage.

My test result: enter image description here

  • I can see in the screenshot that your page starts with Migrated_ . Since I use -TakeSourcePageName:$true I do not get any pages with that name. Are you suggesting using -TakeSourcePageName:$false as a workaround? I am using SharePointPnPPowerShellOnline 3.26.2010.0
    – Gunilla
    Oct 20, 2020 at 12:07
  • According to my test, this attribute in the command will not affect the result.
    – Amos
    Oct 21, 2020 at 2:51
  • The issue with -TakeSourcePageName:$true is very reproducible on my side. Even if I change settings like locale and sort order from Swedish to English, I get links pointing to Previous_xxx.aspx in the migrated pages. But with -TakeSourcePageName:$false the links are correct in the Migrated_xxx.aspx page. So a workaround for me could be to use -TakeSourcePageName:$false instead and then write some scripts renaming the pages to their proper names.
    – Gunilla
    Oct 21, 2020 at 11:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.