Tuesday, May 14, 2013

Powershell Internationalization

When you need you script work in all computers around the world, please define a cultureinfo ("en-US" cultureinfo for example)
(below an example in my 'french' computer)
$date = Get-Date            
$culture = New-Object System.Globalization.cultureinfo("en-US")         
$date
samedi 4 mai 2013 09:55:18


$date.Tostring("dddd",$culture)
Saturday


$date.Tostring("D",$culture)
Saturday, May 04, 2013


$culture = New-Object System.Globalization.cultureinfo("fr-FR")
$date
samedi 4 mai 2013 09:55:18


$date.Tostring("dddd",$culture)
samedi


$date.Tostring("D",$culture)
samedi 4 mai 2013


Culture List here or in this old cultureinfo Framework information.To play with different pattern culture go to datetimeformatinfo

No comments: