We use cookies to improve your experience.
By your continued use of this site you accept such use.
For more details please see our privacy policy and cookies policy.

Script repository

Computers that have Adaxes Password Self-Service Client installed

December 11, 2023 Views: 2741

This script creates a CSV file specifying, on which of the domain computers Adaxes Password Self-Service Client is installed. To execute the script, create a scheduled task configured for the Domain object type and add a managed domain to the Activity Scope. The domain does not determine the computers to include into the CSV file and will only be used to execute the scheduled task itself.

Note: The script uses cmdlets from Adaxes PowerShell module for Active Directory. To run the script, you need to install the PowerShell Module for Active Directory component of Adaxes.

Parameters:

  • $csvFilePath - specifies the CSV file path.
Edit Remove
PowerShell
Import-Module Adaxes

$csvFilePath = "\\SERVER\Share\Self-Service Client Report.csv"

$computers = Get-AdmComputer -Filter *

$report = @()
foreach ($computer in $computers)
{
    $computerDN = New-Object "Softerra.Adaxes.Ldap.DN" $computer.DistinguishedName
    
    # Set default values for variables
    $reportRecord = New-Object PSObject
    $reportRecord | Add-Member NoteProperty ComputerName $computer.Name
    $reportRecord | Add-Member NoteProperty ParentDN $computerDN.Parent
    $reportRecord | Add-Member NoteProperty AdaxesSelfServiceClientStatus $NULL
    $reportRecord | Add-Member NoteProperty ComputerStatus $NULL
    $reportRecord | Add-Member NoteProperty ErrorMessage $NULL
    
    # Connect to the remote computer using WMI
    try
    {
        $programInfos = Get-WmiObject -ComputerName $computer.Name -Class Win32_Product -ErrorAction Stop | Select-Object Name, InstallState
        $reportRecord.ComputerStatus = "Online"
    }
    catch
    {
        # Computer is offline
        $programInfos = @()
        $reportRecord.ComputerStatus = "Computer is unavailable"
        $reportRecord.AdaxesSelfServiceClientStatus = "Can not determine"
        $reportRecord.ErrorMessage = $_.Exception.Message
        $report += $reportRecord
        continue
    }

    # Search for Adaxes Self-Service Client
    $installedState = "Not Installed"
    foreach ($programInfo in $programInfos)
    {
        if ($programInfo.Name -ine "Adaxes Self-Service Client")
        {
            continue
        }

        switch ($programInfo.InstallState)
        {
            -6
            {
                $installedState = "Bad Configuration"
            }
            -2
            {
                $installedState = "Invalid Argument"
            }
            -1
            {
                $installedState = "Unknown Package"
            }
            1
            {
                $installedState = "Advertised"
            }
            2
            {
                $installedState = "Absent"
            }
            5
            {
                $installedState = "Installed"
            }
        }

        break
    }

    # Add the computer to the report
    $reportRecord.AdaxesSelfServiceClientStatus = $installedState
    $report += $reportRecord
}

# Export report to file
if ($report.Length -gt 0)
{
    $report | Export-Csv $csvFilePath -NoTypeInformation
}
Comments 0
Leave a comment
Loading...

Got questions?

Support Questions & Answers