Last active
October 10, 2019 14:53
-
-
Save joerodgers/024df25deac8d53cf0a8f6aefa2df66a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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