Monday 25 May 2009

Get-RegionInfo

  1. <# 
  2. .SYNOPSIS 
  3.     This script displaysthe property values for a globlisation region 
  4. .DESCRIPTION 
  5.     This script 
  6. .NOTES 
  7.     File Name  : Get-RegionInfo.ps1 
  8.     Author     : Thomas Lee - tfl@psp.co.uk 
  9.     Requires   : PowerShell V2 CTP3 
  10. .LINK 
  11.     This script posted to: 
  12.         http://www.pshscripts.blogspot.com 
  13.     MSDN Sample posted at: 
  14.         http://msdn.microsoft.com/en-us/library/system.globalization.regioninfo.aspx 
  15. .EXAMPLE 
  16.     PSH [C:\foo]: .\Get-RegionInfo.ps1' 
  17.     Name:                         US 
  18.     DisplayName:                  United States 
  19.     EnglishName:                  United States 
  20.     IsMetric:                     False 
  21.     ThreeLetterISORegionName:     USA 
  22.     ThreeLetterWindowsRegionName: USA 
  23.     TwoLetterISORegionName:       US 
  24.     CurrencySymbol:               $ 
  25.     ISOCurrencySymbol:            USD 
  26.  
  27.    The two RegionInfo instances are equal. 
  28.      
  29. #> 
  30.   
  31. ## 
  32. # start of script 
  33. ## 
  34.   
  35. # greate a region 
  36.  
  37. $myRI1 = New-Object System.Globalization.RegionInfo "US"  
  38. "   Name:                         {0}" -f $myRI1.Name 
  39. "   DisplayName:                  {0}" -f $myRI1.DisplayName 
  40. "   EnglishName:                  {0}" -f $myRI1.EnglishName 
  41. "   IsMetric:                     {0}" -f $myRI1.IsMetric 
  42. "   ThreeLetterISORegionName:     {0}" -f $myRI1.ThreeLetterISORegionName 
  43. "   ThreeLetterWindowsRegionName: {0}" -f $myRI1.ThreeLetterWindowsRegionName 
  44. "   TwoLetterISORegionName:       {0}" -f $myRI1.TwoLetterISORegionName  
  45. "   CurrencySymbol:               {0}" -f $myRI1.CurrencySymbol  
  46. "   ISOCurrencySymbol:            {0}" -f $myRI1.ISOCurrencySymbol  
  47. "" 
  48.  
  49. # Compare the RegionInfo above with another RegionInfo created using CultureInfo 
  50. $culinfo = New-Object system.Globalization.CultureInfo "en-us", $false 
  51. $myRI2   = New-Object System.Globalization.RegionInfo $culinfo.lcid 
  52.  if ( $myRI1.Equals( $myRI2 )) { 
  53.    "The two RegionInfo instances are equal." 
  54. else
  55.    "The two RegionInfo instances are NOT equal." 
  56.     

No comments: