I have a PowerShell script creating new site collections, each containing a root SPWeb, on my SharePoint web application.
I have a THMX file that I'm trying to apply to each SPWeb that the script creates, but I'm not sure how best to do this.
- I can use ThmxTheme.Open(site, URL) to get a handle to the theme once it is uploaded.
- I can use ThmxTheme.ApplyTo(web) to apply the theme to the SPWeb once I have the handle to it.
- However, I can't figure out how to upload the theme in the script.
In the past, I've scripted the uploading of images to a site's Asset Library, for example, but I can't find the equivalent of SPWeb.Lists.EnsureSiteAssetsLibrary() to get a handle to the Theme Gallery.
Can anyone tell me
- how to get the THMX file into the theme gallery, and
- if there's an easier way to script setting the theme to an SPWeb than that bulleted above (e.g. if there's a way to get a handle to the theme without needing a server-relative URL)?