ComputerConsulting Posted February 12, 2017 Posted February 12, 2017 It would be helpful to be able to enable maintenance mode in a script and disable it in another script. See if this makes sense. Script 1 = turns on maintenance mode Script 2 = reboots computer Script 3 = turns off maintenance mode Would this work, and how would one do this? This would be a lot simpler than setting a time for maintenance mode in the agent and be more useful since maintenance mode wouldn't depend on a time, but on a script no matter when it runs.
Administrators Paul Posted February 13, 2017 Administrators Posted February 13, 2017 I doubt that script 3 will execute. We don't continue a task execution after a reboot. If you need to schedule a reboot for your systems I recommend you to configure the Maintenance Schedule on your machines (can also be done via a Pulseway Group Policy). Powershell to control the maintenance mode: Set-ItemProperty -Path "HKLM:\Software\MMSOFT Design\PC Monitor" -Name "MaintenanceMode" -Value "1" -Paul David- 1
ComputerConsulting Posted February 13, 2017 Author Posted February 13, 2017 (edited) 22 minutes ago, Paul said: I doubt that script 3 will execute. We don't continue a task execution after a reboot. If you need to schedule a reboot for your systems I recommend you to configure the Maintenance Schedule on your machines (can also be done via a Pulseway Group Policy). Powershell to control the maintenance mode: Set-ItemProperty -Path "HKLM:\Software\MMSOFT Design\PC Monitor" -Name "MaintenanceMode" -Value "1" -Paul Why wouldn't script 3 work? The value would = 0 instead of 1 to turn it off again. I'll have to test it, but wouldn't issuing a registry entry via the powershell overwrite the previous entry with value = 1 with the value = 0? I could set a powershell script to execute for all my nodes at a certain time each morning to make sure all nodes are NOT in maintenance mode. Wouldn't it also work, if I split it into two tasks instead of one? The first task would set maintenance mode on do what it needs to do, and then reboot. The second task timed to run 30 minutes later would then take the computer or computers out of maintenance mode. One more question about my post above: After changing the registry entry, would that require a reboot or will the Pulseway Agent see that the registry has been changed, and act accordingly? Edited February 13, 2017 by ComputerConsulting I have ADHD and I drink.
Administrators Paul Posted February 13, 2017 Administrators Posted February 13, 2017 If you configure two tasks then it will work. The registry change is detected within 15 seconds. -Paul
ComputerConsulting Posted February 13, 2017 Author Posted February 13, 2017 3 minutes ago, Paul said: If you configure two tasks then it will work. The registry change is detected within 15 seconds. -Paul Excellent. That was the answer I was looking for, and can't wait to try it. Now for the icing on the cake: How do I make a script pause for 15 seconds?
kavaa Posted February 13, 2017 Posted February 13, 2017 @ComputerConsulting add this to your PowerShell Script: Start-Sleep -s 15 Than it will wait 15 Sec.
ComputerConsulting Posted February 13, 2017 Author Posted February 13, 2017 Thank you, everyone. That was perfect. I executed the scripts from my Web Browser and watched the results on my phone. It took 5 seconds to go into maintenance mode and exiting was almost immediate. So cool.
Administrators Paul Posted February 13, 2017 Administrators Posted February 13, 2017 Glad to hear it works . -Paul
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now