So i need a script that would change the date and time to a specific date and time. My problem is that i need a cycle of 24 hours on one specific date and then it goes back 24 so the date does not change. For ex. 25. 1. 2021 00:00:00 Am ----> 25. 1. 2021 11:59:59 Pm ----> 25. 1. 2021 00:00:00 Am and so on. I tried to run a script in powershell that would run every 24 hours every day, but in Task scheduler it moves the next trigger day by 24 hours so if i run the script on the 25. 1. 2021 11:59:59 Pm the next trigger day is on the 26. 01. 2021 and that is 48 hours and then on 27. 01. 2021 and so on. Is there a solution for this problem? The code that i run
Register-ScheduledJob -Name 'XXXX' -FilePath 'C\\\.ps1' -Trigger (New-JobTrigger -Once -At "12:00 am" -RepetitionInterval (New-TimeSpan -Minutes 1440) -RepetitionDuration ([TimeSpan]::MaxValue))
In the file`function Set-Time([string]$dateTime)
{
$newDate = Get-Date $dateTime
Set-Date $newDate
}
Set-Time 'Monday, January 25,2021 12:00:00 AM'`