PowerShell Automation TimeZone so confusing

Dear Adam,
i was playing with script schedule in PA and found that time zone is so confusing and cannot find documentation on how to use it so for example my PSU is running on IIS and server time zone UTC
which is +4 hours ahead of my time in u.s.east

when i pick a schedule and select today date and time to run a script the admin page will save my changes and show me exactly what i have picked based on my current u.s.east time but the script will not run.
when i check the schedules.ps1 script i found time zone ‘America/New_York’ and the time is UTC (PSU server time)
in order for me to execute the script let say 2 minutes from now i had to pick the UTC time of the server and add 2 minutes so the admin page will show me a time 4 hours ahead of mine and the script will execute.
so i cannot understand how PSU is managing the time zone and how can a user schedule a script execution on future time with different time zone
a working example with 2 different time zone will be much appreciated.

Thank you

Product: PowerShell Universal
Version: 1.5.17

This sounds like a bug to me. The time zone setting should be taking effect independent of the server time zone.

I can reproduce this. We are doing a time zone conversion incorrectly. I’ll get this fixed for 1.5.19

Thank you adam

Any Idea when version 1.5.19 included this fix will be released?

I’ll be releasing a build this week to resolve this issue and a few others. Probably in a couple of days. I can kick off a nightly build of 1.5 so you can grab it earlier if you would like. I’ll start that now.

Build 828960966 has this fix.

https://imsreleases.z19.web.core.windows.net/

thank you adam

error on description when trying to schedule script run in 1.5.19 nightly

Failed to format description: The conversion could not be completed because the supplied DateTime did not have the Kind property set correctly. For example, when the Kind property is DateTimeKind.Local, the source time zone must be TimeZoneInfo.Local. (Parameter ‘sourceTimeZone’)

script didnt run.

Can you share what your schedules.ps1 looks like?

all what am doing is to chose todays date and todays time and add just 2 minutes after to test run

New-PSUSchedule -Script “Script1.ps1” -TimeZone “America/New_York” -OneTime ‘2021-05-11T00:02:34.0000000Z’-Environment “default”

with version 1.5.18 i had to edit the script after schedule and add 4 more hours on it to get to run after 2 min like this

New-PSUSchedule -Script “Script1.ps1” -TimeZone “America/New_York” -OneTime ‘2021-05-11T04:02:34.0000000Z’-Environment “default”

in version 1.5.19 you pinged me even that didnt work and the description instead of saying Runs one time. it just says the error above no matter what time or date i chose.

Hmmm. This “fix” is broken…I’ll take another look at this tomorrow. I’m pretty certain I tried a script almost exactly like that so I might need to mess around with it more.

k thank you

Can you try to adjust this by removing the Z identifier at the end of the time.

New-PSUSchedule -Script “Script1.ps1” -TimeZone “America/New_York” -OneTime ‘2021-05-11T04:02:34.0000000’-Environment “default”

sure ill test it now

am currently on version 1.5.18 i just went to my automation screen and set a scheduled to run after 2 min from current time
my machine am logged in to is E.S.T timezone
my PSU is hosted on a server running UTC timezone

a scheduled created in schedule.ps1 script as follows

New-PSUSchedule -Script “Script1.ps1” -TimeZone “America/New_York” -OneTime ‘2021-05-11T14:02:24.0000000Z’-Environment “7.2”

i did remove the ‘Z’ from string , my Automation screen shows

which reflect current server timezone

script didnt run.

if i put the ‘Z’ back then the screen will change to

which should be correct based on my timezone

Weird. Ok. Thanks for trying. In my lab I was seeing that when I didn’t have the Z, it would fail with the error you mentioned and then if I removed it everything was correct. I’ll continue to test and adjust the time zones more to see if I can see your behavior.

by the way as extra information i did try something without using GUI
i did the code manually and put UTC timezone and put server time + 2min and it did run on time

the issue is happening up to version 1.5.18 when PSU detect the logged in user time zone and convert it to server time , you will see the time is correct but the script wont run

like for me since it detect timezone America/New-york i had to remodify the created schedule and add 4 more hours for it to run correctly.