Forum Discussion

CaseyW's avatar
11 months ago
Solved

How to create datasources from powershell script

Hello, I wrote a PS script that takes a look at all issued certs on my microsoft CA and outputs 4 columns, The name of the cert, the effective date, the expiration date and the days remaining until ...
  • Stuart_Weenig's avatar
    11 months ago

    Alright, assuming you’re not going to be running this code on your collector but on different systems, you’ll have to put your script into a scriptblock and run it as shown here.

    Assuming your common names in production will actually be unique, just use for loop to make your discovery scriptblock write-host output look like this:

    cert.domain.com##cert.domain.com
    cert.domain.com##cert.domain.com
    cert.domain.com##cert.domain.com
    cert.domain.com##cert.domain.com

    And use pretty much the same code (but different for loop) to make your collection scriptblock write-host this

    cert.domain.com.daysRemaining: 112
    cert.domain.com.daysRemaining: 121
    cert.domain.com.daysRemaining: 305
    cert.domain.com.daysRemaining: 310

    Then just setup a datapoint using ‘multiline key-value pairs’ and make the interpreter “##WILDVALUE##.daysRemaining”.

    Then just set whatever threshold you want on that datapoint.

    Have you checked that this has not already been built by someone else?