BatchPatch Forums Home › Forums › BatchPatch Support Forum › Local Command – Powershell script not working
- This topic has 3 replies, 2 voices, and was last updated 4 years, 2 months ago by doug.
-
AuthorPosts
-
August 24, 2020 at 2:38 pm #12479Magnus KnightParticipant
I’m sorry if this is long-winded, It just seems to be an odd problem, so I want to give all of the relevant information.
I have some Windows servers that require special attention when patching. I have to use Microsoft Powershell scripts, along with advanced multi-row sequence to perform tasks in a certain order to make sure these servers are protected.
Part of this is,
I have to stop a service (in this case Microsoft SQL Server)
Check to verify the service is indeed stopped
Take a VMware snapshot
Patch the system
Verify it comes back up with no issues
Then remove the VMware snapshotThis works fine with all servers, except one. I have one MS-SQL server, that when the powershell script runs to stop the SQL service, the service doesn’t stop. Then because of the checks I have the advanced multi-row sequence fails. I’m glad the advanced multi-row sequence fails, but my issue is why isn’t the SQL service stopping when being executed by the advanced multi-row sequence?
The advanced multi-row sequence is calling on a Local Command, which executes the powershell script to stop the service. I have been trying to get this to work for months, and it fails every time at this same place. If I manually tell BatchPatch to execute the local command, then the script works fine. It only fails when it’s done as part of the advanced multi-row sequence.
I’ve tested the script many times and it works. It’s also the same script I use for other servers which also work; just the computer name is different.
Any help with this is very much appreciated!
August 24, 2020 at 3:57 pm #12487dougModeratorWithout being able to see the exact detail of everything that is happening, it’s hard for me to know what might be going on. If you have active support with us, you are welcomed to reach out to us directly for troubleshooting assistance. That way we would be able to view more details about what is happening. Otherwise my best suggestions are as follows:
1. You said you’re running a local command. Local commands execute on the BatchPatch computer, not on the target computer. It’s unclear to me exactly how your queue is structured, but if you are running a local command to execute the script, then I assume the script is making a remote call to the target computer. Since you’re using powershell, maybe check the powershell permissions and execution policy to make sure that what you’re doing is not being blocked.
2. Maybe just try a different method for stopping the service. For example instead of using a local command that calls a custom powershell script that makes a remote call to the target computer, maybe just try a remote command directly from BP with the following syntax, substituting the SQL service’s caption instead of ‘DNS Client’ (I don’t know what the exact SQL caption naming is off the top of my head):
WMIC SERVICE where caption='DNS Client' CALL stopservice
August 25, 2020 at 11:53 am #12488Magnus KnightParticipantThanks Doug,
I did just send a support request, in case that may help solve this issue.
Regarding suggestion #1, I would think the script isn’t being blocked from running on the target machine since when I manually tell BatchPatch to execute this job queue it works fine, and when I run the powershell script manually it works fine. It only fails this when running as part of the advanced multi-row sequence. I’m not claiming to be an expert with this, it just seems odd that it would behave that way.
I’ll look into trying method #2 that you suggested. I don’t really care how I get the service to stop, as long as I can get it stop. These servers only patch (and have a maintenance window) once per month, so unfortunately it will be a while before I can test and troubleshoot this alternative method.
August 25, 2020 at 12:37 pm #12489dougModeratorThanks. I just replied to your email. It really doesn’t make any sense to me how/why it would fail only when executed as part of the advanced sequence, but I’ll have a better sense of things after I get the requested items in the email. Let’s switch over to email from this point forward. I will come back and update this thread if/when we figure out what’s going on.
-
AuthorPosts
- You must be logged in to reply to this topic.