- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2021 11:30 AM
My company is in the process of migrating probes to patterns, and I'm currently working on the SQL Server Instance class pattern "MSSql DB On Windows".
Our probe discovery had a customized powershell script that retrieved SQL Server Always On/Availability Group information. I'm trying to run this custom script in a pattern step using the KB article How to run powershell script in patterns, but not having luck. I've tried using the "Set Parameter Value" step with an EVAL() statement in the value, as well as the "Parse Command Output" step. Neither is producing results for me. Error info provided below.
The powershell script i need to run is a lot more complex than the examples provided by the KB article, but I have to believe there's a way to accomplish what I need.
Can someone please help?
I've attached the PS script that I'd like to run. Here's the error info that I get when I try to test using the "Parse Command Output" command
Groovy code failure: startup failed: Pattern: null, Step: Untitled Step, Hash: 52905630: 8: unexpected token: $myInstanceName @ line 8, column 50. ryAvailabilityGroup ([string] $myInstanc ^ 1 error
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2021 05:56 AM
as
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2021 10:22 AM
The issue via patterns is that powershell is run from cmd; so a lot of escaping/joining/line terminating needs to be put in place to prevent the cmd shell from incorrectly interpreting things like a pipe, breaks or even quotes.
This helped me a lot:
https://stackoverflow.com/questions/45224759/using-multi-line-powershell-commands-from-cmd-exe
Also, patterns can drop a file and then trigger it; that might be a better option for you considering the complexity of your script. The files I've seen so far OOB are much simpler, but they don't have any of the funky escaping; just looks like normal powershell.
Take a look at the Windows OS - Servers pattern : Windows - Cloud : Windows - AWS or Windows - Azure to see and example of putting a file then running it. I think the script would need to be loaded to 'Uploaded Files' under the Pattern Designer application.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2021 05:37 AM
Thank you for the response! I ended up using the put file method you described.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2021 05:56 AM
as
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2025 09:22 PM
hi @andy m_1
I have a similar requirement, I am trying to add .ps1 file to Uploaded files but .ps1 file is not allowed as attachment. How did you upload it?