Site Definitions not available in Powershell

Here is an interesting little quirk.  I was recently setting up some installation scripts which would roll in a Site Definition, then tried to create a Site Collection from the newly installed Site Definition.  And no matter what I tried, PowerShell would not see the newly installed Site Definition.

If I looked at the list of available Site Templates in the UI, the new Site Template was there and I could create it.

Thanks to Steve Clement on this one, as it seems there is some odd kind of caching going on.  The Powershell context only sees the SharePoint site template list at the point at which the object is created, which means our new site template does not appear.

Steve has a solution involving a new PowerShell plug-in which effectively recycles the SharePoint context.  I’ll have a play with that in a while, but for now, I split the process into two separate scripts, one which installs the solutions and the other which creates the Site Collection.

So, want to install a Site Template via PowerShell and create a Site Collection base don it in one single script?  Out of the box, it seems, you can’t.

Advertisements

Posted on October 4, 2013, in SharePoint and tagged , , . Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: