Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clear PowerShell Sharepoint Cache?

I have an odd problem:

I deployed a WSP package containing stuff and a site template using PowerShell

Add-SPSolution ...
Install-SPSolution ...

When now trying to create a new Site Collection, my template is visible and I can create a new site collection with my template.

When I try to look at all the installed site templates with PowerShell (Get-SPWebTemplate) in the same session as before, the new template does not appear!

The same goes visa-versa: When retracting/deleting the solution, I cannot create a new site collection with the template anymore since it's gone. But in the still open PowerShell session the template is still visible.

The only solution: Open up a new PowerShell session after the solution has been retracted/deployed - only in this "fresh" session, the changes are synchronized.

My question is: How do I clear this PowerShell cache? How do I fetch the site template list directly from the server and not from some cache?

Some other guy also came up with closing/re-opening PowerShell (PowerShell caching leads to head-banging) - this can't be the solution...

Disclaimer: Cross post from "How to clear PowerShell Object Model Cache".

like image 575
Dennis G Avatar asked Feb 22 '11 13:02

Dennis G


1 Answers

Turns out that PowerShell is actually caching some stuff in particular the OWSSVR.DLL.

There are two (and ½) ways to overcome the problem:

  1. Use a nifty PowerShell snippet to kill a Sharepoint thread and reload a DLL
  2. Use a different PowerShell session started from within the first session
  3. Use old-school stsadm to create the site as stsadm lives within another thread and hence "sees" the new site templates already

I went with method 2 ½ (denoted 3) as it is just the easiest using a one-liner stsadm instead of calling up yet another PS session.

like image 87
Dennis G Avatar answered Oct 18 '22 01:10

Dennis G