Joe Tran

PowerShell -- Instance Property Support

Recommended Posts

It had been ages since I had to write a datasource in PowerShell so I haven't stayed up-to-date on the latest bells and whistles available. But I was very surprised to see that instance properties are still not supported. With the substitution engine and enhancements made on the Groovy-side, I would have thought this trivial to implement. Is supporting instance properties on the horizon for PowerShell scripting for Datasources?

Share this post


Link to post
Share on other sites

Creating instance (auto) properties or attempting to use instance auto properties created from the AD script in the collection script?

Share this post


Link to post
Share on other sites

Hi Joe,

Instance Level Properties (ILP's) are available in PowerShell Active Discovery scripts as long as they fit the following format as output. 

https://www.logicmonitor.com/support/datasources/active-discovery/script-active-discovery/

instance5_id##instance5_name##instance5_description####auto.fooProperty=somevalue&auto.barProperty=anothervalue
instance6_id##instance6_name##instance6_description####auto.fooProperty=thisvalue&auto.barProperty=thatvalue

Is this what you are trying to accomplish? Or are you trying to use a Powershell PropertySource?

Share this post


Link to post
Share on other sites

Sorry for being unclear. I was attempting to consume instance level properties in a PowerShell collection script. 

The PowerShell Collection script tried assigning two ILPs to a variable-- one was a JSON formatted string (auto.events) and another was a plain ol' string (auto.logname). Like so:

$events = '##AUTO.EVENTS##'
$logname = "##AUTO.LOGNAME##"

It took a little testing and debugging to figure out that my attempts to iterate through  the JSON object were failing because the substitution engine were making these empty strings O.o.

Share this post


Link to post
Share on other sites

Interesting, and works in Groovy? I haven't though of doing it that way before, learn something new :)

I typically would either have the same basic code from AD in the collector script (since I attempt to use BatchScript whenever possible) or pass values over via wildvalue/wildvalue2/wildalias.

Share this post


Link to post
Share on other sites

You are correct in groovy you can do an instanceProps.get() – return the specified instance property e.g. instance = instanceProps.get("wildvalue")

This is available if you import the santaba module for Groovy. Unfortunately, we don't have anything like that for Powershell at this time.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now