1

I am attempting to upload a new Master Page to a SharePoint 2013 site using Powershell.

I am copying the .html file to the "Master Page Gallery" list successfully but I cannot find any way of having the .master file generated without manually visiting the Design Manager in my web browser.

Is it possible to upload a .html Master Page through Powershell and have the .master generated so I can set it as the default Master Page?

2

I found I needed to add it, check it out, call update, check it in and publish it. So:

    $web = Get-SPWeb $site

    $folder = $web.getfolder("_catalogs/masterpage")
    $files = $folder.Files
    $mPage = Get-Item "C:\path to your\masterpage.html"
    $file = $files.Add("masterpage.html", $mPage.OpenRead(), $true)
    $file.CheckOut()        
    $file.update()
    $file.CheckIn("")
    $file.Publish("")
  • I had to do something similar to this. Previously I was calling .update() on the File but I needed to call .update() on the list Item instead – AverageMarcus Jan 18 '16 at 11:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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