Product: PowerShell Universal Version: 3.9.1
I am trying to schedule a script to run from another script, 30 minutes in the future, but having problems getting it to do so.
Here is the code:
$Date = (get-date).AddMinutes(30).ToString(“MM/dd/yyyy HH:mm:ss”)
New-PSUSchedule -Script “Email.ps1” -OneTime $Date -Name “User Email” -TimeZone America/Phoenix
I have tried with and without the timezone, various date formats, and I can get it 7 hours prior or more, but never to be 30 minutes in the future. I assume it is the date string, and I could probably add the 7 hours, (Arizona is -7) but that seems a bit janky.
It is part of a larger user creation process and the automated email goes out about 30 minutes after the account is created to allow time for O365 to actually create the account and mailbox.