Nick Grattan’s SharePoint Blog

About Microsoft SharePoint and some .NET

Setting Regional Settings with PowerShell

with 2 comments

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.

Written by Nick Grattan

September 3, 2007 at 11:26 am

2 Responses

Subscribe to comments with RSS.

  1. 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

  2. Iain,
    Thanks for the correction. I’ve updated the post.
    Nick.

    Nick Grattan

    November 14, 2008 at 2:17 pm


Leave a Reply