This script creates a CSV file specifying, on which of the domain computers Adaxes Password Self-Service Client is installed.
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.
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
}