Setting Regional Settings with PowerShell
This blog entry describes how to use Microsoft PowerShell with the SharePoint and MOSS 2007 object model. Here is an example script that allows the regional settings for a site to be changed and follows the C# example presented here.
$spsite=[Microsoft.SharePoint.SPSite](“http://localhost:9000“)
$rootWebSite=$spsite.RootWeb
$website=$spsite.OpenWeb($rootWebSite.ID)
$culture=[System.Globalization.CultureInfo]::CreateSpecificCulture(“en-GB”)
$website.Locale=$culture
$website.Update()
$website.Dispose()
$rootWebSite.Dispose()
$spsite.Dispose()
Save the file with a “ps1” extension, e.g. “locale.ps1”. The script can be executed in PowerShell by typing:
./Locale.ps1
Note that even if the script file is in the current folder you still need to use the “./” notation to qualify the filename.
This was really useful, saved me figuring out the cultureinfo call in powershell. However for me the en-uk string needed to be en-gb.
Cheers,
Iain
Iain Wyatt
November 14, 2008 at 12:12 pm
Iain,
Thanks for the correction. I’ve updated the post.
Nick.
Nick Grattan
November 14, 2008 at 2:17 pm