Security

 View Only
Expand all | Collapse all

OnGuard Health Collection Scripts

This thread has been viewed 10 times
  • 1.  OnGuard Health Collection Scripts

    Posted May 19, 2025 06:47 PM
    Edited by mohanad.abdalrazik@outlook.com May 19, 2025 06:48 PM

    Hi everyone,

    i have a task to configure Health Collection Script to check if the windows activated or not, based on the returned value user will be healthy or not.

    this is PowerShell script 

    # Get activation status

    $activationStatus = Get-CimInstance -Query "Select * from SoftwareLicensingProduct where PartialProductKey is not null and LicenseStatus = 1"

    # Build output message

    if ($activationStatus) {

        $output = @{ activationStatus = "Windows is activated." }

    } else {

        $output = @{ activationStatus = "Windows is NOT activated." }

    }

    # Convert to JSON

    $output | ConvertTo-Json

    access tracker logs:

     what im missing? because "activationStatus" parameter not returned to ClearPass, i tried to run the script manually it's working successfully

    I'm also confused because the exit code is 0 which means 



    ------------------------------
    BR,
    Mohanad
    ------------------------------



  • 2.  RE: OnGuard Health Collection Scripts

    Posted May 20, 2025 12:58 AM

    Try this PS Script:

    # Get activation status
    $activationStatus = Get-CimInstance -Query "SELECT * FROM SoftwareLicensingProduct WHERE PartialProductKey IS NOT NULL AND LicenseStatus = 1"

    # Evaluate activation and return appropriate status
    if ($activationStatus) {
        Write-Output "Windows is activated."
        exit 0  # Healthy
    } else {
        Write-Output "Windows is NOT activated."
        exit 1  # Unhealthy
    }



    ------------------------------
    Shpat | ACEP | ACMP | ACCP | ACDP
    Just an Aruba enthusiast and contributor by cases
    If you find my comment helpful, KUDOS are appreciated.
    ------------------------------