了解get-culture命令 [英] Understanding the get-culture command

查看:93
本文介绍了了解get-culture命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我在Powershell脚本中依赖于文化的返回值遇到了一些麻烦.同一脚本返回不同的值,具体取决于它是哪台计算机.因此,我认为可能是区域性设置不同,并且对于一台服务器,它返回了.

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

另一个就像是: zh-CN

一个值代表键盘设置,而另一个(第二个)代表什么?

One value is for the keyboard settings but what does the other (second) stand for?

第二个值是绑定到OS安装的,还是仅仅是一个设置?Powershell中有命令更改该值吗?

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?

当然我首先阅读了Gelp get-help get-culture

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.

但是我对此不满意.

推荐答案

Cmdlet的帮助 Get-Culture 包含副标题名称​​相关链接.请注意最后两行.

The help for the Cmdlet Get-Culture contains a subheading name related links. Please note the last 2 lines.

相关链接
联机版本: http://go.microsoft.com/fwlink/p/?linkid=293965
设定文化
Get-UICulture

Related Links
Online Version: http://go.microsoft.com/fwlink/p/?linkid=293965
Set-Culture
Get-UICulture

搜索帮助时,还使用 Get-Command Cmdlet.

When searching for help also use the Get-Command Cmdlet.

Get-Command "*culture*"

您可以使用内置的 Powershell 变量查看当前文化".

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', $_ ) 
}

进一步阅读:

Tobias Weltner整理了一组非常有用的 pdf 三是文化.
另外,在提示符下:

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

这篇关于了解get-culture命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆