Sunday, 13 December 2009

Get-LocaleCurrency.ps1

  1. <# 
  2. .SYNOPSIS 
  3.     This script displays a number formatted in Currency for each locale 
  4. .DESCRIPTION 
  5.     This script first creates a value to be formatted, and creates an array 
  6.     containing all the locales defined on the system. The script then uses  
  7.     each locale to format the value as currency. 
  8. .NOTES 
  9.     File Name  : Get-LocaleCurrency.ps1 
  10.     Author     : Thomas Lee - tfl@psp.co.uk 
  11.     Requires   : PowerShell V2 
  12. .LINK 
  13.     This script posted to: 
  14.         http://www.pshscripts.blogspot.com 
  15. .EXAMPLE 
  16.     Left as an exercise for the reader! NB: the output will look better 
  17.     is this script is run in PowerShell ISE vs PowerShell console. 
  18.      
  19. #> 
  20. ## 
  21. # Start of script 
  22. ## 
  23.   
  24. #Create a value to be formatted 
  25. [int] $Value = 100 
  26.  
  27. # get all hte locales defined in the system 
  28. $L=[system.Globalization.CultureInfo]::GetCultures('AllCultures') | sort lcid 
  29.  
  30. foreach ($C in $L) { 
  31.  
  32. $C=New-Object System.Globalization.CultureInfo $C.Name 
  33. if (!$C.IsNeutralCulture){ 
  34.    "{0,-50} {1,-6}  {2}" -f $C.Displayname,$C.Name,$Value.ToString("C",$c
  35.    } 

No comments: