How to start a mid server script file from run script activity?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-20-2017 12:15 PM
Is it possible to start a mid server script file from a run script activity instead of attaching it to a custom powershell activity? The Docs only covered the latter.
- Labels:
-
Orchestration

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-20-2017 02:26 PM
Hi Aaron,
I actually have done a fair amount of research in the past, and I'll explain an alternate method that runs from the run script activity. The short answer is, it isn't as easy, so prepare yourself! As you may know, all the external reaching scripts all go through the ECC Queue, I recommend reading up on it. This trick basically creates a Probe ie making an ECC Queue input/output record, and it executes the powershell.
You'll need a defined Discovery Probe to make this work though (Discovery Definitions -> Probes -> New). Then you'll need to set the ECC queue topic to Command, and ECC queue name to be powershell C:\MyScriptHere.ps1 for example. Command executes the probe name with cmd in windows. I have mine pointed to my dev mid server's agent script folder, this is the default folder for the MID Server scripts.
After that, you need to kick off that cool probe you just made via a Run Script or Scheduled Job or BR. You can do this by using a rather undocumented SN API called SncProbe. I picked up the syntax from an OOB script include (you can also do this manually using a GlideRecord insert, but I digress). You set the source to be the local MID server, and your name, etc to match the above Probe. Note that you have to comment out the \ signs here since it's Javascript.
var probe = SncProbe.get("Snapshot");
- probe.setName("powershell D:\\MidServerDev\\agent\\scripts\\Snapshot.ps1");
- probe.setSource("127.0.0.1");
//probe.addParameter("script.ps1","get-service -name sn_mid_server -computername ' + start_host + ' | set-service -status running");
- probe.addParameter("skip_sensor", false);
- probe.create("YOUR-MIDSERVER-FQDN");
I never experimented with passing parameters but I know it's possible. See the commented out syntax above.
Hope this helps you out. Please follow up if you have questions. This way worked best for me.
Tyler Teter