<# .SYNOPSIS Peripolos Collector for Windows - collects software metadata for a free Peripolos First Article Check. .DESCRIPTION Read-only. Makes NO network connections and changes nothing on this computer. It writes one JSON file in the current folder. Open the file, review it, then upload it yourself at https://www.virtual-infra.com/peripolos.html Collected: Windows edition, version and build; installed software names, versions and publishers; installed update IDs (KB numbers); the machine's role (workstation, server, domain controller). Not collected: IP or MAC addresses, user names, serial numbers, files, documents, logs, passwords, or any CUI. The computer name is replaced with an anonymous label unless you add -IncludeHostname. Works on PowerShell 2.0 and later (Windows 7 / Server 2008 R2 onward). Administrator rights are not required. .PARAMETER Category How VIS should treat this machine: it (default), ot (HMI, engineering workstation, historian, SCADA server) or edge (internet-facing server, VPN or remote-access host). .PARAMETER IncludeHostname Keep the real computer name in the file instead of an anonymous label. .PARAMETER OutputFolder Folder for the output file. Defaults to the current folder. .PARAMETER Merge Combine several collector files (for example from a shared folder after a GPO run) into one upload file. .EXAMPLE powershell -ExecutionPolicy Bypass -File .\peripolos-collector.ps1 -Category ot .EXAMPLE powershell -ExecutionPolicy Bypass -File .\peripolos-collector.ps1 -Merge "\\fileserver\peripolos\*.json" #> param( [ValidateSet("it", "ot", "edge")] [string]$Category = "it", [switch]$IncludeHostname, [string]$OutputFolder = (Get-Location).Path, [string]$Merge ) $CollectorVersion = "1.0.1" # Resolve the output folder to a full path so .NET file calls write where PowerShell expects if (-not (Test-Path -LiteralPath $OutputFolder)) { New-Item -ItemType Directory -Path $OutputFolder | Out-Null } $OutputFolder = (Resolve-Path -LiteralPath $OutputFolder).ProviderPath $Schema = "peripolos-inventory/1" $UploadUrl = "https://www.virtual-infra.com/peripolos.html" # JSON is built by hand because PowerShell 2.0 has no ConvertTo-Json function ConvertTo-JsonString([string]$Value) { if ($Value -eq $null) { return "null" } $sb = New-Object System.Text.StringBuilder [void]$sb.Append('"') foreach ($ch in $Value.ToCharArray()) { $code = [int]$ch if ($ch -eq '"') { [void]$sb.Append('\"') } elseif ($ch -eq '\') { [void]$sb.Append('\\') } elseif ($code -lt 32) { [void]$sb.Append(('\u{0:x4}' -f $code)) } else { [void]$sb.Append($ch) } } [void]$sb.Append('"') return $sb.ToString() } # Strips anything that looks like an IP address, MAC address or email from names (never from version numbers) function Remove-Identifiers([string]$Text) { if (-not $Text) { return "" } if ($Text.Length -gt 300) { $Text = $Text.Substring(0, 300) } $Text = $Text -replace '[\w.+-]{1,64}@[\w-]{1,63}(?:\.[\w-]{1,63}){1,8}', '[email]' $Text = $Text -replace '\b(?:[0-9A-Fa-f]{2}[:-]){5}[0-9A-Fa-f]{2}\b', '[mac]' $Text = $Text -replace '(?