Have a look here: http://blogs.msdn.com/b/powershell/archive/2006/04/25/583235.aspx
and here: http://poshcode.org/2226:
function Set-Culture([System.Globalization.CultureInfo] $culture)
{
[System.Threading.Thread]::CurrentThread.CurrentUICulture = $culture
[System.Threading.Thread]::CurrentThread.CurrentCulture = $culture
}
Additional Info
To find which values can be used for $culture
:
This will give you a list of Culture Types:
[Enum]::GetValues([System.Globalization.CultureTypes])
Selecting one of the above types (e.g. AllCultures) you can then list the available values of that type:
[System.Globalization.CultureInfo]::GetCultures( [System.Globalization.CultureTypes]::AllCultures )
You can then use the Name or Number of the culture you're interested in with the GetCultureInfo
method to retrieve the value you're after:
$culture = [System.Globalization.CultureInfo]::GetCultureInfo(1033)
$culture = [System.Globalization.CultureInfo]::GetCultureInfo('en-US')
NB: Thanks to implicit conversion, you could just pass the culture name or number (i.e. as a string or integer) to the Set-Culture
method which would automatically be converted to the expected CultureInfo value.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…