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?

1 Answer 1

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("")
1
  • 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 Commented Jan 18, 2016 at 11:19

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.