PowerShell script to change the locale (regional settings) for each site in a given site collection, as by default the locale is set to en-US (United States). It leverages the Get-SPWeb command to enumerate sub-sites. Here is the script
# ======================================================
#
# SharePoint 2010 PowerShell script to change the locale
# setting for all sites within a given Site collection
#
# ======================================================
# -------------
# Set variables
# -------------
$Site = "http://intranet"
$NewLocale = "en-GB"
$Webs = Get-SPWeb -Site $Site
# ------------
# Begin script
# ------------
ForEach ($Web In $Webs)
{
If ($Web.locale -ne $NewLocale)
{
Write-Host $Web.title "- " -NoNewLine; Write-Host "changing from" $Web.locale "to" $NewLocale -ForegroundColor "Green"
$Web.Locale = $NewLocale
$Web.Update()
$Web.Dispose()
}
Else
{
Write-Host $Web.title "- " -NoNewLine; Write-Host "already set to" NewLocale -ForegroundColor "Blue"
}
}
And here is a screenshot of the output, colour coded to make it easier to read:
No comments:
Post a Comment