Forum Discussion

SikkuSamra's avatar
10 months ago

Batch PowerShell Script

Hello!  I am running a batch PowerShell script in LogicMonitor. My intended purpose is to extract the end date SAML certificate of a Enterprise Application in my Azure environment. My Active discove...
  • Mike_Moniz's avatar
    10 months ago

    When you use the BATCH type of script (instead of SCRIPT type) in a DataSource, the wildvalue will not exist because your script will need to output all instances all at once. So for example if you have a DataSource autodiscover that provides 4 instances called A,B,C and D you need your script to output something like this:

    A.DaysLeft=1
    B.DaysLeft=6
    C.DaysLeft=13
    D.DaysLeft=11

    The difference between BATCH and SCRIPT types, is that BATCH needs to provide all the answers at one time as it will be run only once. The SCRIPT type will run once for each instance and LM will pass along that instance in the ##wildvalue## text.

    So your script would need look something like this (pseudocode code):

    Get-AzAdServicePrincipal -All | ForEach-Object {
    $CertExpires = ($_.PasswordCredentials.EndDateTime[0] - $(Get-Date)).Days
    Write-Output “$($_.Name).DaysLeft=$CertExpires"
    }