Wednesday, 25 August 2010

Get-NoDstTimeZones

  1. <# 
  2. .SYNOPSIS 
  3.     This script displays those time zones that do NOT support 
  4.     daylight savings time. 
  5. .DESCRIPTION 
  6.     This script uses .NET to get the time zones defined on a system 
  7.     then displays those that do not suport daylight savings time. 
  8. .NOTES 
  9.     File Name  : Get-NoDstTimeZones.ps1 
  10.     Author     : Thomas Lee - tfl@psp.co.uk 
  11.     Requires   : PowerShell Version 2.0 
  12. .LINK 
  13.     This script posted to: 
  14.         http://www.pshscripts.blogspot.com 
  15.     MSDN Sample posted at: 
  16.        http://msdn.microsoft.com/en-us/library/system.timezoneinfo.supportsdaylightsavingtime.aspx 
  17. .EXAMPLE 
  18.     PSH [C:\foo]: .\Get-NoDstTimeZones.ps1' 
  19.     (UTC) Coordinated Universal Time 
  20.     (UTC) Monrovia, Reykjavik 
  21.     (UTC+01:00) West Central Africa 
  22.     ... {output snipped to save space} 
  23. #> 
  24.  
  25. # Get Time Zones 
  26. $zones = [System.TimeZoneInfo]::GetSystemTimeZones() 
  27.  
  28. # For each zone, display name if the zone does not support dst 
  29. foreach($zone in $zones) { 
  30.    if (! $zone.SupportsDaylightSavingTime) {$zone.DisplayName} 

No comments: