Tuesday 31 August 2010

Get-Cultures.ps1

  1. <# 
  2. .SYNOPSIS 
  3.     This script displays information of cultures on a system. 
  4. .DESCRIPTION 
  5.     This script reimplements an MSDN script using PowerShell. It first 
  6.     gets the cultures then displays them 
  7. .NOTES 
  8.     File Name  : Get-Cultures.ps1 
  9.     Author     : Thomas Lee - tfl@psp.co.uk 
  10.     Requires   : PowerShell Version 2.0 
  11. .LINK 
  12.     This script posted to: 
  13.         http://pshscripts.blogspot.com/2010/08/get-cultures.html 
  14.     MSDN sample posted to: 
  15.         http://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo.getcultures.aspx  
  16. .EXAMPLE 
  17.     PSH [C:\foo]: .\Get-Cultures.ps1' 
  18.     CULTURE ISO ISO WIN DISPLAYNAME                             NATIVENAME 
  19.     af       af  afr AFK Afrikaans                               Afrikaans 
  20.     am       am  amh AMH Amharic                                 Amharic 
  21.     ar       ar  ara ARA Arabic                                  Arabic 
  22.     arn      arn arn MPD Mapudungun                              Mapudungun 
  23.     as       as  asm ASM Assamese                                Assamese 
  24.     az       az  aze AZE Azeri                                   Azeri 
  25.     az-Cyrl  az  aze AZC Azeri (Cyrillic)                        Azeri (Cyrillic) 
  26.     az-Latn  az  aze AZE Azeri (Latin)                           Azeri (Latin) 
  27.     ... snipped to save space! 
  28. #> 
  29.  
  30. # Get Cultures 
  31. $Cultures = [System.Globalization.CultureInfo]::GetCultures([System.Globalization.CultureTypes]::NeutralCultures) 
  32.  
  33. # Display header then details 
  34. "CULTURE ISO ISO WIN DISPLAYNAME                             NATIVENAME" 
  35. foreach ($Ci in $Cultures
  36.       { 
  37. "{0,-8} {1,-3} {2,-3} {3,-3} {4,-40}{4,-40}" -f $Ci.Name, 
  38.              $Ci.TwoLetterISOLanguageName, 
  39.              $Ci.ThreeLetterISOLanguageName,   
  40.              $Ci.ThreeLetterWindowsLanguageName, 
  41.              $Ci.DisplayName, 
  42.              $Ci.NativeName 

No comments: