Skip to content

Instantly share code, notes, and snippets.

@joerodgers
Last active October 10, 2019 14:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joerodgers/024df25deac8d53cf0a8f6aefa2df66a to your computer and use it in GitHub Desktop.
Save joerodgers/024df25deac8d53cf0a8f6aefa2df66a to your computer and use it in GitHub Desktop.
Add-PSSnapin Microsoft.SharePoint.PowerShell
function Remove-ComposedLook
{
[cmdletbinding()]
param
(
[Parameter(Mandatory=$true)][string]$Name,
[Parameter(Mandatory=$true)][Microsoft.SharePoint.SPWeb]$Web
)
$designGallery = $web.GetCatalog([Microsoft.SharePoint.SPListTemplateType]::DesignCatalog)
if( $designGallery )
{
$composedLooks = $designGallery.GetItems(
(New-Object Microsoft.SharePoint.SPQuery -Property @{
ViewXml = "<View><Query><Where><Eq><FieldRef Name='Name' /><Value Type='Text'>$Name</Value></Eq></Where></Query></View>"
ViewFields = "<FieldRef Name='Name'/>"
ViewFieldsOnly = $true
}))
for($x = 0; $x -lt $composedLooks.Count; $x++ )
{
$composedLooks[$x].Delete()
}
}
}
$allsites = Get-SPSite -Limit All
foreach( $site in $allsites )
{
# remove the composed look called "Current" from each web in the site collection
$site| Get-SPweb -Limit All | % { Remove-ComposedLook -Web $_ -Name "Current" }
# reset the site back to the default "office" theme on each web in the site collection
$site| Get-SPweb -Limit All | % { [Microsoft.SharePoint.Utilities.ThmxTheme]::RemoveThemeFromWeb($_, $true <# delete theme files #> ) }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment