Forum Discussion

Joe_Tran's avatar
Joe_Tran
Icon for Advisor rankAdvisor
7 years ago

PowerShell -- Instance Property Support

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?

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

  • 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?

  • 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.

  • Interesting, and works in Groovy? I haven't though of doing it that way before, learn something new :)/emoticons/smile@2x.png 2x" title=":)" width="20">

    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.

  • 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.

  • Bump.  This is still not working, i.e. getting Instance Level Properties (ILPs) in DataSource written in PowerShell.  I just burned 8 hours trying to figure out why my script during Collection is coming up with empty strings during assignments of some custom ILPs.  Sigh.