Batch PowerShell Script

  • 8 February 2024
  • 2 replies

Badge +1


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 discovery script runs perfectly. However when I test my collector script, it believes my ##WILDVALUE## is an empty string. When I poll for the data for my instance, it retrieves the correct value. However, No Data gets returned when I enable my instances. My WILDVALUE does not contain any of the invalid characters. 

My Datapoint is in the format of ##WILDVALUE##.key

$EnterpriseAppSingle = "##WILDVALUE##"
$EnterpriseApp = Get-AzAdServicePrincipal -ObjectID $EnterpriseAppSingle
$CertExpires = ($EnterpriseApp.PasswordCredentials.EndDateTime[0] - $(Get-Date)).Days
write-host “##WILDVALUE##.DaysLeft=$CertExpires"

Any insight to this would be helpful! 


Best answer by Mike Moniz 8 February 2024, 18:17

View original

2 replies

Userlevel 6
Badge +11

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:


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"


Badge +1

Mike you are THE MAN. Thank you for taking the time to explain this! I will adjust accordingly.