Automating baseline deployment of patch cycle

I’m also trying to use REST API’s to automate patch deployments on existing baselines. We have a 2 week patching cycle where week 1 is dev/test and week 2 is production. I have a powershell script working that will execute the xml based on the baseline and computer group but I’m manually calculating the start and end time since the value is based on when the job is scheduled. We have about 20 groups for dev/test and 30 for production that have to be manually scheduled each week. I’m looking for guidance on how I can accomplish this by just executing the powershell script. I’m also open to other ideas that would make the scheduling easier and less prone to user mistakes.