BatchPatch Forums Home › Forums › BatchPatch Support Forum › Job Queue – custom sequence
- This topic has 1 reply, 2 voices, and was last updated 2 years, 9 months ago by doug.
-
AuthorPosts
-
February 16, 2022 at 4:11 am #13326Johan LundqvistParticipant
Hi all!
I’m in the process of trying to automate patching with BatchPatch and I’m trying to set up a Job Queue with some custom steps. Some actions are aldready build in but I have some problems to get it just right.
My goal is:
1. Check pending reboot….
2. Check client if any user is logged in – If yes, then force logoff
3. Check for updates and reboot – always
4. Wait for server to get online
5. Then I want to check for updates again and reboot – if required (Sometimes updates show up after a reboot)
6. Send e-mail notification
So I want the server to check for updates and repeat the cycle as long there are available updates.
BUT my main issue is the 2nd bullet……how can I check if a user is logged on and force a logoff? I don’t find any build-in actions so maybe I need to execute some kind off script here?
Hope you guys can help me a bit….
Thanks…
February 16, 2022 at 7:51 am #13327dougModeratorMy first question is what is the purpose of having step 2? What is the advantage to checking for a logged-on user and logging that user off before you reboot in the following step? And what is the purpose for even checking pending reboot if you’re going to reboot no matter what in step 3? Why not just skip those steps? In the queue you posted they appear to have no real utility that I can discern. What I mean is that a reboot will automatically log the user off anyway, so what advantage is there to logging the user off first and then doing the reboot? For what you have described it seems sufficient to simply do the reboot.
Additionally, consider that what you’re describing with first checking to see if anyone is logged on before executing a logoff procedure would also be unnecessary. That is, if you really want to perform a logoff operation separately from a reboot, you could simply execute a logoff command without ever checking to see if anyone is logged-on. Simply executing a logoff command would be sufficient. It wouldn’t matter whether or not someone was logged on or not.
You can use the following syntax inside of a BatchPatch remote command to perform a standard logoff:
powershell.exe -ExecutionPolicy Bypass -command "(Get-WmiObject -Class Win32_OperatingSystem).Win32Shutdown(0)"
or a forced logoff:
powershell.exe -ExecutionPolicy Bypass -command "(Get-WmiObject -Class Win32_OperatingSystem).Win32Shutdown(4)"
-
AuthorPosts
- You must be logged in to reply to this topic.