简体   繁体   English

更改芬兰语Windows Server 2008 R2上Powershell脚本的文化

[英]Change culture on Finnish Windows Server 2008 R2 for Powershell Script

I am making a script that gets a bunch of tags and outputting it to a CSV file. 我正在制作一个脚本,该脚本获取一堆标签并将其输出到CSV文件。 The database in question only allows for a specific date input ("dd-mmm-yyyy hh:mm:ss") when requesting the tags. 所涉及的数据库在请求标签时仅允许输入特定日期(“ dd-mmm-yyyy hh:mm:ss”)。 However the server I am running the script on is in finland and using finnish culture for powershell. 但是,我正在运行脚本的服务器在芬兰,并且使用芬兰文化进行Powershell。 So when I type: 所以当我输入:

Get-Date

I get everything in finnish: 我用芬兰语得到了所有东西:

6. joulukuuta 2017 13:37:47

I really want 06-dec-2017 13:37:47 我真的想要2017年12月6日13:37:47

I am unable to use the " Set-Location " because this command does not work in Windows Server 2008 R2. 我无法使用“ Set-Location ”,因为此命令在Windows Server 2008 R2中不起作用。

So I need help. 所以我需要帮助。 When I type: 当我输入:

(get-date).ToString("dd-mmm-yyyy hh:mm:ss")

I want it to output 06-dec-2017 12.41.23 我希望它输出2017年12月6日12.41.23

You could use the -Format paramter of Get-Date 您可以使用Get-Date的-Format参数

Get-Date -Format "dd-MMM-yyy HH:mm:ss"

This will return the hour in 24 hour format, use hh instead of HH for the 12 hour format. 这将以24小时格式返回小时,对于12小时格式,请使用hh代替HH。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM