Specifying a result using WMI

I have been trying to build a SAM component using WMI monitor to get the license status of a node in my environment, however all I seem to be able to get is the test coming back as "Up". 


I have gone through as many links and URLs as I can find on Thwack trying to get this to display a result that is actually meaningful, but I appear to be struggling. 

I have even attempted using powershell to get this, however my powershell knowledge is sparse and although I get a result which can be translated, it appears I cannot get it in to a format that SolarWinds can utilise. 

Any assistance would be greatly appreciated  

  • You're right, polling and presenting text values is not something that Orion is great at, although the API poller seems to be getting there. 

    You're also right that a PowerShell monitor is probably what will ultimately work best for this question. There are a number of Q/As that explain the approach already here on Thwack, but if you want to share the code that you've tested so far, we will gladly try to help you get it over the finish line! The key is that SAM's PowerShell script monitors allow you to pull a numeric statistic result (this is what gets evaluated) but it also lets you return a message with that result, and this message can contain the string that you want to show.

  • Hi sturdyerde, 

    Thank you for your reply!

    I have been working on a powershell script too, however my results on it show it as "Not defined", if I make changes to the current script, it fails. 

        Get-CimInstance -ClassName SoftwareLicensingProduct -computerName $args.get(0) |
         where PartialProductKey | select Pscomputername,Name,@{Name='LicenseStatus';Exp={
            switch ($_.LicenseStatus)
        0 {'Unlicensed'}
        1 {'licensed'}
        2 {'OOBGrace'}
        3 {'OOTGrace'}
        4 {'NonGenuineGrace'}
        5 {'Notification'}
        6 {'ExtendedGrace'}
        Default {'Undetected'}

    In all honesty, I am not fussed which way we can get this working, I would be happy for me to have something I can run a report off of  

    Many thanks again  

  •  I remember helping out someone with a similar issue a while back. Take a look at this Thwack Article 

    You may have to change the powershell to get a different stat but should have a lot of what you want like how to poll this data via a powershell script, have SW write it to a Custom Property which you can then create a report off. 

    let me know if anything needs to be modified or you need guidance on any of it.

  • Hi 

    Thank you for your response. 

    I have attempted this, but I can't seem to get the syntax correct. 

    When I do the Write-Host and Write-Message comments, they either fail or I am getting something completely different rather than the "licensed" status. 

  •  is the above your complete script? if not are you able to post it here?

  •  Perhaps the below script will work as a component monitor, I suspect that your original script may have been missing a statistic and exit code which are requirements for script monitors.

    $licensestatus= Get-CimInstance -ClassName SoftwareLicensingProduct -computerName localhost |
         where PartialProductKey | select Pscomputername,Name,@{Name='LicenseStatus';Exp={
            switch ($_.LicenseStatus)
        0 {'Unlicensed'; break}
        1 {'Licensed'; break}
        2 {'OOBGrace'; break}
        3 {'OOTGrace'; break}
        4 {'NonGenuineGrace'; break}
        5 {'Notification'; break}
        6 {'ExtendedGrace'; break}
        Default {'Undetected'; break}
    if ($licensestatus.LicenseStatus -ne "licensed") 
    Write-Host "Message: $($licensestatus.LicenseStatus)"
    Write-Host "Statistic: 1"
    #Exit 3
    Write-Host "Message: $($licensestatus.LicenseStatus)"
    Write-Host "Statistic: 0"
    #Exit 0
  • Hi  

    Unfortunately, i didn't see your message on Friday, however the script you posted on Saturday has worked! 
    Many thanks for this!

    You were right, I don't think I had the outputs scripted properly. My statements were incomplete, and I completely messed up the output. 

    Thanks again!