Files
Samsara/powershell/Get-ServerSystem.ps1
oceans2alaska 610a3bb447 Privacy hardening, remote-peer IP masking and review fixes
- Add privacy projection (core/privacy.py), private report storage, bounded
  process capture; omit identities, free text and unapproved paths
- Mask remote peer IPs: only loopback/host/wildcard stay numeric, others are
  reduced to remote_scope private/public (schema + scoring updated)
- Map ss TCP states to canonical names; ASCII-only numeric fields; fix
  "Microsoft Visual C++" product matching (Python and PowerShell)
- Merge 7fed3b9: -Diagnostic switch, serialization exit code 3, PS7 module
  path, UI error detail; keep hardened task/certificate collectors
- Add audit docs, privacy docs and regression tests

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-04 18:50:24 -08:00

37 lines
2.4 KiB
PowerShell

function Get-SamsaraSystem {
param($Result)
$Result.data = [ordered]@{
hostname = 'Host-0001'; platform = 'windows'
collection_source = 'Local Windows read-only collection'
operating_system = 'Not collected'; os_version = 'Not collected'; os_build = 'Not collected'
product_type = 0; last_boot = 'Not collected'; ip_addresses = @(); network_adapters = @()
domain = 'Not collected'; domain_joined = $null
}
Get-SamsaraPrivacyConfiguration
if ($script:SamsaraPrivacy.approved_hostnames -ccontains [Environment]::MachineName) { $Result.data.hostname = [Environment]::MachineName }
Invoke-SamsaraRead $Result 'OS identity' {
$os = Get-CimInstance -ClassName Win32_OperatingSystem -Property Version,BuildNumber,LastBootUpTime,ProductType -ErrorAction Stop
$years = @{ '14393' = '2016'; '17763' = '2019'; '20348' = '2022'; '26100' = '2025' }
if ([int]$os.ProductType -notin @(2,3) -or -not $years.ContainsKey([string]$os.BuildNumber)) {
throw 'Unsupported Windows release or workstation edition.'
}
$Result.data.operating_system = 'Windows Server ' + $years[[string]$os.BuildNumber]
$Result.data.os_version = $years[[string]$os.BuildNumber]
$Result.data.os_build = [string]$os.BuildNumber
$Result.data.kernel_version = [string]$os.Version
$Result.data.product_type = [int]$os.ProductType
$Result.data.last_boot = $os.LastBootUpTime.ToUniversalTime().ToString('o')
}
Invoke-SamsaraRead $Result 'Computer domain membership' {
$computer = Get-CimInstance -ClassName Win32_ComputerSystem -Property PartOfDomain -ErrorAction Stop
$Result.data.domain = 'Domain identity omitted'
$Result.data.domain_joined = [bool]$computer.PartOfDomain
}
Invoke-SamsaraRead $Result 'Network adapter configuration' {
$adapters = @(Get-CimInstance -ClassName Win32_NetworkAdapterConfiguration -Filter 'IPEnabled = True' -Property IPAddress -ErrorAction Stop)
$Result.data.network_adapters = @($adapters | ForEach-Object -Begin { $i = 0 } -Process { $i++; 'Adapter-' + $i })
$Result.data.ip_addresses = @($adapters | ForEach-Object { foreach ($address in $_.IPAddress) { [string]$address } })
}
$Result.limitations += 'Identity and addresses are local observations. No DNS probes or Active Directory enrichment were performed.'
}