0

Is there a powershell command to determine the name of the theme is used by webs under a site collection? If yes, is there a powershell way to dissassociate the theme from a web or all the webs under a given site collection?

  • Can you explain what you're trying to accomplish? I ask because you can't disassociate a theme...you can apply a new one. This can be done thru the UI or via the OM. The UI has the added benefit of cascading the change down to any subsites that are inheriting from their parent site. – Rob D'Oria Jul 26 '11 at 18:09
1

You can attach the object model via Powershell. There are no native cmdlets.

$site = Get-SPsite "url"
$web = $site.OpenWeb()
$theme = [Microsoft.SharePoint.Utilities.ThmxTheme]::GetManagedThemes($site)

You can then loop thru the collection to see all the themes assigned.

You can call various methods to manage your themes in this way.

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.utilities.thmxtheme_members.aspx

These are disposable object so you need to manage them or use the Start / Stop-SPAssigment

Vijai has posted some other examples for working with themes: http://www.go4sharepoint.com/Code/remove-sharepoint-site-theme-powershell-318.aspx

http://www.go4sharepoint.com/Code/change-sharepoint-site-theme-powershell-319.aspx

  • $site=Get-SPSite "Sales.NortelNetwork.com/NW" $web=$site.OpenWeb() [Microsoft.SharePoint.Utilities.ThmxTheme]::RemoveThemeFromWeb($web,$false) $web.Update() $web.Dispose() I went to sp manager and the old theme is still in there. hmm $site.Dispose() – Robert Half Jul 26 '11 at 19:19
0

Gary Lapointe's STSADM extensions might be useful here, albeit for 2007. It looks like there's a 2010 command available here.

Here is a reference on how to set it automatically with code, it could probably be tweaked to reset it to Default.

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.