Add local Windows Server inventory collection and validation; include core package

This commit is contained in:
2026-10-30 11:24:40 -07:00
parent 967b2bd46a
commit f65ade9fff
35 changed files with 2200 additions and 56 deletions

View File

@@ -0,0 +1,37 @@
function Read-SamsaraSoftwareEntries {
param($Result, $Uninstall, [string]$View)
foreach ($name in $Uninstall.GetSubKeyNames()) {
$entry = $null
try {
$entry = $Uninstall.OpenSubKey($name, $false)
if ($null -eq $entry) { throw 'Software entry not readable.' }
$display = [string]$entry.GetValue('DisplayName')
if ($display) {
$Result.data += [pscustomobject]@{ name = $display; publisher = [string]$entry.GetValue('Publisher')
version = [string]$entry.GetValue('DisplayVersion'); installation_date = [string]$entry.GetValue('InstallDate')
registry_view = $View }
}
} catch { Add-SamsaraError $Result $_ 'Machine software entry' }
finally { if ($entry) { $entry.Dispose() } }
}
}
function Get-SamsaraSoftware {
param($Result)
# Explicit registry views avoid 32-bit redirection and require no installer queries.
foreach ($view in @([Microsoft.Win32.RegistryView]::Registry64, [Microsoft.Win32.RegistryView]::Registry32)) {
Invoke-SamsaraRead $Result ('Machine software registry ' + [string]$view) {
$hive = $null; $uninstall = $null
try {
$hive = [Microsoft.Win32.RegistryKey]::OpenBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine, $view)
$uninstall = $hive.OpenSubKey('SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall', $false)
if ($null -eq $uninstall) { return }
Read-SamsaraSoftwareEntries $Result $uninstall ([string]$view)
} finally {
if ($uninstall) { $uninstall.Dispose() }
if ($hive) { $hive.Dispose() }
}
}
}
$Result.limitations += 'Machine uninstall registrations in both registry views only. Per-user, portable, container and unregistered software may be absent. Install dates are raw registry values and may be empty. No installer consistency checks are triggered.'
}