Wednesday 28 January 2009

Get-TimeZoneInfo.ps1

  1. <#
  2. .SYNOPSIS
  3. Gets and displays time zone information via WMI
  4. .DESCRIPTION
  5. This script uses the Win32_TimeZone class to obtain, then
  6. display time zone information for a computer.
  7. This script is a MSDN sample recoded in PowerShell
  8. .NOTES
  9. File Name : Get-TimeZoneInfo.ps1
  10. Author : Thomas Lee - tfl@psp.co.uk
  11. Requires : PowerShell V2 CTP3
  12. .LINK
  13. Script posted to:
  14. http://www.pshscripts.blogspot.com/2009/01/get-timezoneinfops1.html
  15. MSDN Sample at:
  16. http://msdn.microsoft.com/en-us/library/aa394590(VS.85).aspx
  17. .EXAMPLE
  18. [ps] c:\foo> .\Get-TimeZoneInfo.ps1
  19. Time zone information on computer "Win7"
  20. Time Zone Description : (UTC) Dublin, Edinburgh, Lisbon, London
  21. Daylight Name : GMT Daylight Time
  22. Standard Name : GMT Standard Time
  23. #>

  24. ###
  25. # Start of Script
  26. ##

  27. # Get Time Zone on a computer
  28. $Computer = "."
  29. $timezone = Get-WMIObject -class Win32_TimeZone -ComputerName $computer

  30. # Display details
  31. if ($computer -eq ".") {$computer = Hostname}
  32. "Time zone information on computer `"{0}`"" -f $computer
  33. "Time Zone Description : {0}" -f $timezone.Description
  34. "Daylight Name : {0}" -f $timezone.DaylightName
  35. "Standard Name : {0}" -f $timezone.StandardName
  36. #End of Script

No comments: