I want to perform a reboot on Windows 7 and 10 computers but I first need to put the Jenkins nodes temporarily offline. Before I perform the reboot, I need for any running tasks to finish. Then I login remotely into the servers and restart the computers. Before I restart the computers however, I need to make sure that there is enough space in the computer. If there is more than 75% of the space occupied, I need to delete files that are dated long ago. After clearing up some space, I restart the computers. I wait until the restart is finished and then put nodes back online.
This is the task I am trying to automate using a script. How can I script this? I am currently manually doing these steps but I want to try and automate it. I was thinking of using Powershell in restarting the computers but I am not sure how to actually do it.