This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

Component Statistic is Zero - PowerShell Script

$eCerts = Get-ChildItem -Path cert:\LocalMachine -Recurse -ExpiringInDays 90

Write-Host "Statistic:" $eCerts.Count

Write-Host "Message:" $eCerts.SerialNumber $eCerts.NotAfter $eCerts.Subject

Exit 0

Above is the script which runs fine and returns expected results in the script editor and on the remote server. Testing is 100% successful.

The issue is that the statistic field shows a zero and not 1 as the script result shows. Message shows the three fields fine.

Component monitor platform is set to x64. Valid credentials in place. Execution Mode: Remote Protocol: HTTP

Under Script Output

pastedImage_1.png

SAM Version is 6.6.0

pastedImage_0.png

  • Is there a reason that you're converting the returned value and then rounding it?

    Could it be that you're sending exit code 0 as a result? This script should still work in your component monitor if you remove the "exit 0" statement, and I think it will pass the correct value.

  • No reason for the rounding.

    Exit code 0 is for script completion status, yes script works without it.

    No does not pass the correct value with or without exit 0 statement.

    SCRIPTS MUST REPORT STATUS THROUGH EXIT CODES says the linked document below.

    The Basics of PowerShell (part 3)

  • Same code works for me as you'd expect. I get one hit and the statistic shows 1 with the message details.

    If you test the code from the application template to you get the statistic of 1 or the 0?

    If you run the code from the machine directly do you get the expected result?

    Assuming you do, you might be having an odd Orion issue. I've seen some instances in our environment where the statistics aren't fully updated. It seems related to subscriptions at times and I've been able to resolve it by moving the node to another poller and then back again if you have an APE and it's the same issue might be worth a try.

    Can also try just a simple unmanage / wait five minutes / remanage. That's where I would start anyway.

  • Unmanage/Remanage did not help. Same results.

    Code tests fine all other methods. Get 1 from the template and on the box itself.

  • Starting to sound like the subscriptions issue to me more.

    Try to move it between APEs if you can as this is the least invasive fix I've found.

    If it's a new monitor and you're not worried about history, delete and re-create the monitor.

    This may be affecting more than just this one monitor depending on the issue, so you can try a simple service restart or clearing subscriptions:

    Success Center

    Part of how I've noticed this in the past for our environment is running the application in debug mode in Orion and checking the script outputs. If you're seeing the debug showing statistic: 1, but it's not updating in the database, then this is how I've resolved it in the past. I'd be curious if there are other ideas as well.

    Success Center

  • The powershell script runs as expected. Services and server has been restarted with no luck.

    Not sure what you accomplished with the debugging.

    Pretty much all basic trouble-shooting has not yielded any positive results.

  • Did you enable debugging on the application to review the logs? That's the jist of it, we're likely going to get a pointer for the next piece of the puzzle by reviewing what's in the debug logs.

    The point in revealing it was just sharing my story on how I've discovered and resolved similar issues by enabling the debugging logs, if the throughput is showing up correctly in the logs then it would suggest to me the subscription issue that I mentioned, otherwise we will hopefully see an error.

    If you're able to enable and share the logs here I'd be happy to take a look, otherwise if you're not comfortable with that you'll want to work with Support on it.

  • Application Debug shows the following:

    Statistic: 1

    Errors:      ====================================================

    Result:      ====================================================

    Component Evidence Type: DynamicEvidence

    Component Type: WindowsPowerShell

    Actual Outcome: Undefined

    Registered Errors:

    Dynamic Monitor Result Info:

    Outcome based on statistic thresholds: Undefined

  • Fixed:

    The Count statistic as difference: True was the issue. As soon as I changed it to false, the number showed up and everything worked as expected.

    Thanks everyone for your assist, especially jrouviere jrouviere

    BTW, Support case can be closed.