Discovery Pattern Step - Need help formatting a powershell script for use in pattern designer

andy m_1
Giga Contributor

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

 

 

 

1 ACCEPTED SOLUTION

andy m_1
Giga Contributor

as @ggarcia suggested, I was able to accomplish my goals by uploading my ps script to the "uploaded files" table under pattern designer, using a "put file" step to select the powershell file, then parse command output to execute the file.   The oob pattern example was very helpful - Windows OS - Servers pattern : Windows -Cloud : Windows - AWS or Windows - Azure.

 

 

 

find_real_file.png

 

 

find_real_file.png

 

View solution in original post

7 REPLIES 7

Rinku1
Tera Contributor

Hello guys,

I am having similar requirement where powershell scripts is required to get some data....I followed what @ggarcia  has suggested but I'm unable to load ps script to the "uploaded files" table under pattern designer, it is giving me error "prohibited file extension error" while uploading my ps script.

 

Any advise would be appreciated.

 

Regards,

Rinku

Check the attachment settings in the instance. Review this kb: https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0718011

Rinku1
Tera Contributor

thanks @ggarcia 

@andym 

 How did you format your ps script in set command details, I tried comparing other patterns but it didn't work.