################################################################################## # # # Script name: Set-Theme.ps1 # Author: goude@powershell.nu # Homepage: www.powershell.nu # # ################################################################################## param ([string]$Url, [string]$Web, [string]$Theme, [switch]$help) function GetHelp() { $HelpText = @" DESCRIPTION NAME: Set-Theme.ps1 Sets the Theme on a SharePoint site PARAMETERS: -Url Name of the Client (Required) -Web Specify the Web you want to Open (Required) -Theme Specify which Theme you want to apply (Required) -help Prints the HelpFile (Optional) SYNTAX: Set-Theme.ps1 -Url http://wss -Web / -Theme Obsidian Sets the Obsidian theme on the RootWeb: http://wss/ Set-Theme.ps1 -Url http://wss -Web Blog -Theme Obsidian Sets the Obsidian them on the Website: http://wss/Blog site. Set-Theme.ps1 -help Displays the help topic for the script Available Themes: "@ $HelpText Get-ChildItem "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\THEMES" | Where { $_.Mode -match "d-" } | Select Name } function Set-Theme($URL, $CurrentSite, $Theme) { # Load Assemblies [System.Reflection.Assembly]::LoadWithPartialName("System.Web") | Out-Null [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") | Out-Null $Site = New-Object Microsoft.SharePoint.SPSite($URL) $Web = $Site.OpenWeb($CurrentSite) $Web.ApplyTheme($Theme) $Web.Update() # Dispose Used Objects $Site.Dispose() $Web.Dispose() } if($help) { GetHelp } if ($Url -AND $Web -AND $Theme) { Set-Theme $URL $Web $Theme }