Get-DSTInfo - Determine Time Change Information With A Function - Outputs Object

The Get-DSTInfo function will check when a computer is scheduled for Daylight/Standard time changes.  It uses the WMI Win32_TimeZone and Win32_LocalTime class to poll the required information.    

5 Star
4,099 times
Add to favorites
Operating System
E-mail Twitter Digg Facebook
  • Localized day and month names for free
    1 Posts | Last post May 23, 2018
    • Instead of using a switch and hardcoding English, Get-Culture will provide localized day and month names.
      $DSTDoW = (Get-Culture).DateTimeFormat.DayNames[$TimeZone.DaylightDayOfWeek]
      $DSTMonth = (Get-Culture).DateTimeFormat.MonthNames[$TimeZone.DaylightMonth - 1]
      $STNDWeek = (Get-Culture).DateTimeFormat.DayNames[$TimeZone.StandardDayOfWeek]
      $STNDMonth = (Get-Culture).DateTimeFormat.MonthNames[$TimeZone.StandardMonth - 1]
  • Nothing happens and no error
    2 Posts | Last post February 29, 2016
    • I am in the folder of the script and type the following:
      .\Get-DSTInfo -ComputerName SERVERNAME
      I get no error and nothing happens.
    • See the response on April 15, 2014 to load the script and separately use the script.
  • Can you research DST some more?
    1 Posts | Last post February 29, 2016
    • There are places that do not follow the DST practice and the script fails with dstMonth -eq 0.
      Less than 40% of the countries in the world use DST.
      Today clocks are almost always set one hour back or ahead.
      Almost is analogous to not all. Hmmm.... you seem to be US centric with forcing on the hour changes.
      I will go back to my research - trying to determine DST for a lat/lon point on a given date other than current date. That adds to my challenge. I have the POSH code to use a REST api to get the TZ data for a point. But still working on whether the Zulu date/time is DST or not.
  • Script updtade
    1 Posts | Last post February 20, 2016
    • Hi Brian! Is there a newer version of script?
      I am trying to merge operating system information and installed hotfixes to make the script better, but nothing happens.
      Ex: Computer, OSVersion, Specific_hot_fix, etc, etc.....
      Is it possíble? Can you help me?
  • I am getting error when i try to load function.( ..\Get-DSTInfo.ps1 )
    1 Posts | Last post October 12, 2015
    • set-executionpolicy : Windows PowerShell updated your execution policy successfully, but the setting is overridden by a policy defined at a more specific scope.  Due to the override, your shell will retain its current effective
      execution policy of RemoteSigned. Type "Get-ExecutionPolicy -List" to view your execution policy settings. For more
      information please see "Get-Help Set-ExecutionPolicy".
      At line:1 char:1
      + set-executionpolicy –executionpolicy unrestricted
  • Issue with Amman TZ
    1 Posts | Last post March 26, 2015
    • Hi Brian, thanks for the script.
      There seems to be an issue with the Amman TZ. (GMT+2)
      Your script returns:
      DaylightChgDate : 3/26/2015 11:00:00 PM 
      The UI reports the change is 3/27 at 12:00am
      DaylightTime dst = TimeZone.CurrentTimeZone.GetDaylightChanges(DateTime.Now.Year);
      Console.WriteLine("DST Begins: {0} Ends: {1}", dst.Start.ToString(), dst.End.ToString());
      reports DST begins 3/26 23:59:59?
  • No result returned
    2 Posts | Last post April 15, 2014
    • Hi Brian, 
      Thanks for the script, I have run it, but it gave no error nor any result.
      PS D:\james> .\Get-DSTInfo.ps1
      PS D:\james>
      Please advise, many thanks. 
    • James,
      I designed this to reside in memory of your PowerShell session, you would load it as follows, assuming the path to the script is relative to the current prompt location:
      PS C:\> . .\Get-DSTInfo.ps1
      PS C:\> Get-DSTInfo
      This would execute the function on the local machine.
  • Easy question
    2 Posts | Last post April 15, 2014
    • How can I get this to take the input from a text file list of servers?
    • As long as the text file is structured like this:
      You can do something like this:
      $Computers = Get-Content "Path to text file"
      . .\Get-DSTInfo.ps1
      Get-DSTInfo -ComputerName $Computers
  • Great Job! But looks like I found a little bug here.
    5 Posts | Last post October 11, 2012
    • This script works perfect with our Chicago servers (Central Standard Time), but when I scan our servers in Frankfurt Germany (Central European Standard Time), the dates come back with an extra week added onto the chg date.  Everything else comes out correct, but somewhere in the loop it doesnt like CEST/CET..
      Computer          : PQT-04
      CurrentTime       : 10/9/2012 4:47:17 AM
      DaylightName      : Central Europe Daylight Time
      DaylightDay       : Last
      DaylightDayOfWeek : Sunday
      DaylightMonth     : March
      **DaylightChgDate   : 4/1/2012 2:00:00 AM - should be March 25, 2012
      StandardName      : Central Europe Standard Time
      StandardDay       : Last
      StandardDayOfWeek : Sunday
      StandardMonth     : October
      **StandardChgDate   : 11/4/2012 3:00:00 AM - should be October 28, 2012..
      The StandardName,Day,DoW and Month are all correct, but the chgDates for some odd reason don't calculate right.
    • That's interesting, I'll see if I can figure out why it's doing that.
    • I've figured out why it's not reporting the right date, now on to fix it, but just to give you information on why it's happening...
      DaylightDay can equal 1 through 5.  "5" signifying "Last", the problem is there are only 4 Sunday's in March and October of this year, so it isn't calculating correctly.  Here in the states, as you know, it's usually the "Second" Sunday of the month, so I wasn't able to test the "Last" Sunday of a month.  This is interesting and may be fun to figure out how I can correct the code to reflect the data back correctly.  If you don't mind, send me an email, it's in the notes section of the function, I will then send you the new code to test with and see if that will meet your needs.  Thanks for pointing this out and providing feedback.
    • I was able to test the fix and it appears to be working now, please download the new version and let me know if it doesn't work for you.
    • Just tested this and now all the dates are coming back correct. Thanks again Brian!
  • Error with the script
    2 Posts | Last post October 05, 2012
    • Hello, I am very new to scripting. I manged to run the script but really got up to a point where it fails with error as per below.
      Missing opening '(' after keyword 'for'.
      At C:\Scripts\Get-DSTInfo.ps1:69 char:5
      + for l <<<< ater review.
      Anyone know why its happeing, am I running the script in correct version of power shell?
    • Shahidul,
      Are you loading the script as a function?  Load the script as a function and then call it from the PowerShell prompt like you would any other cmdlet.  Here's an example of how this would be done.
      PS C:\> . C:\PathToScript\Get-DSTInfo.ps1
      PS C:\> Get-DSTInfo -ComputerName SERVER01, SERVER02
      Where SERVER01 and SERVER02 are computers you wish to check the status of DST against.