I've found that import-spweb duplicates items in the theme gallery. Using export-spweb and then import-spweb, the target site is doubled up on each of the themes in the theme gallery. Everytime I do another import-spweb on this site collection, even after deleting the site collection and creating a blank one with no template, it adds another copy of each theme to the theme gallery.
So I'd like to write a little PowerShell script that will find duplicates and delete them, but I'm not sure what files I should be deleting. I looked in the "Theme Gallery" list on the SPWeb I've created, but it's items are the actual theme files.
get-spsite | %{
$_.allwebs | %{
$theme_gallery = $_.lists|?{$_.title -eq "Theme Gallery"}
$theme_gallery.items|select name
}
}
output:
How can a Theme be removed from the gallery for a site with PowerShell?