Nick Grattan's Blog

About Microsoft SharePoint, .NET, Natural Language Processing and Machine Learning

Setting Regional Settings with PowerShell

with 8 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.

Advertisements

Written by Nick Grattan

September 3, 2007 at 11:26 am

8 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

  3. Nick,

    Do you have any tips on how I could create a script to remove a user from all site-collections in a webapp?

    Thanks,

    Ray

    Ray Gaida

    January 16, 2009 at 4:40 pm

  4. […] Blog (which has been around since 2007) is: https://nickgrattan.wordpress.com/2007/09/03/setting-regional-settings-with-powershell/ This entry was posted in SharePoint 2007 and tagged Administration, Powershell, SharePoint […]

  5. Thanks for this, it also works as is on SharePoint 2010.

    Adrian

    September 13, 2010 at 1:55 pm

  6. Greetings from Australia.

    Thanks for writing that. I’m a beginner (my 2nd day) and needed to know how to do just that!

    I don’t suppose you’ve ever tried using powershell to return what people are searching for via the site search (ie. keywords, most popular, searches that have returned no results etc)?

    Porscha

    Porscha

    December 1, 2010 at 10:50 am

  7. Great post, can this be expanded to do the sub sites as well? New to Powershell

    Matt

    June 23, 2011 at 4:14 pm

  8. […] You can find an example of creating a script file for chaning a site’s regional settings here. […]


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: