问题
I recently had some trouble with culture dependent returned values from my powershell script. The same script returned different values, depending on which machine it was. So I thought that maybe the culture settings are different and for one server it returned.
get-culture : de-DE
for the other it was like : en-US
One value is for the keyboard settings but what does the other (second) stand for?
And is the second value bound to the OS installation or is that just a setting? Is there a command in powershell to change the value?
Of course I first read the gelp get-help get-culture
DESCRIPTION
The Get-Culture cmdlet gets information about the current culture settings. This includes information about the
current language settings on the system, such as the keyboard layout, and the display format of items such as
numbers, currency, and dates.
But I am not satisfied with it.
回答1:
The help for the Cmdlet Get-Culture contains a subheading name related links. Please note the last 2 lines.
Related Links
Online Version: http://go.microsoft.com/fwlink/p/?linkid=293965
Set-Culture
Get-UICulture
When searching for help also use the Get-Command Cmdlet.
Get-Command "*culture*"
You can view your 'current culture' by using the built in Powershell variables.
$PSCulture
$PSUICulture
The following code block returns the short date pattern of three different cultures.
### Creates an array of cultureinfo objects:
$myCulturesArray = @(
( $myDECulture = New-Object System.Globalization.CultureInfo("de-DE") ),
( $myGBCulture = New-Object System.Globalization.CultureInfo("en-GB") ),
( $myUSCulture = New-Object System.Globalization.CultureInfo("en-US") )
);
### Outputs today's date using each CultureInfo object
$myCulturesArray | foreach {
(Get-date).ToString('d', $_ )
}
Further reading:
Tobias Weltner put together a very useful set of pdfs, volume 3 is on culture.
Also, at the prompt:
Get-Help Get-Culture -Full
help about_Script_Internationalization
来源:https://stackoverflow.com/questions/22797798/understanding-the-get-culture-command