"tzutil.exe" to change the time zone when launched from powershell throws error:

Welcome Forums General PowerShell Q&A "tzutil.exe" to change the time zone when launched from powershell throws error:

This topic contains 5 replies, has 4 voices, and was last updated by

js
 
Participant
1 year ago.

  • Author
    Posts
  • #82661

    Participant
    Points: 0
    Rank: Member

    When I run the following command at powershell command prompt it works fine. It changes the time zone to Easter time zone.

    tzutil.exe /s 'Eastern Standard Time'
    But when I run it the following way, it says

    powershell.exe -ExecutionPolicy Unrestricted -Command tzutil.exe /s 'Eastern Standard Time'

    TZUTIL: Invalid number of arguments for /s.Use TZUTIL /? for a list of valid options.

    I don't understand. any suggestions please?

  • #82664

    Participant
    Points: 0
    Rank: Member

    I'm sorry to answer a question with a question but...
    Is there any reason the powershell cmdlet of Set-Timezone wont work?
    https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/set-timezone?view=powershell-5.1

    • #82672

      Participant
      Points: 0
      Rank: Member

      I looked up about Set-Timezone already. It is available only from Powershell 5.0.
      We are using Powershell 4.0

      thanks much
      I could make it to work. double quotes
      powershell.exe -ExecutionPolicy Unrestricted -Command "tzutil.exe /s 'Eastern Standard Time'"

  • #82666

    Participant
    Points: 1
    Rank: Member

    It's like you are trying to run dir /s inside the PowerShell. Set-TimeZone, what Greg suggests, is a good one. If you still want to stick to tzutil.exe, you can use:
    tzutil.exe /s 'Eastern Standard Time' and save the command to .bat or .cmd. the command prompt will pick it up and run it. You don't need PowerShell to do that.

    • #82673

      Participant
      Points: 0
      Rank: Member

      I am actually using that command from Cloudformation stack template

  • #82676
    js

    Participant
    Points: 219
    Helping Hand
    Rank: Participant
    powershell.exe -ExecutionPolicy Unrestricted -Command tzutil.exe /s "'Eastern Standard Time'"
    

The topic ‘"tzutil.exe" to change the time zone when launched from powershell throws error:’ is closed to new replies.