From 5a31946083d6a97f464001ddf4c5813efac82029 Mon Sep 17 00:00:00 2001 From: Howard Enos Date: Fri, 17 Apr 2026 14:25:33 -0700 Subject: [PATCH] sync: auto-sync from ACG-TECH03L at 2026-04-17 14:25:31 Author: Howard Enos Machine: ACG-TECH03L Timestamp: 2026-04-17 14:25:31 --- .../msp-tools/msp-audit-scripts/workstation_audit.ps1 | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/projects/msp-tools/msp-audit-scripts/workstation_audit.ps1 b/projects/msp-tools/msp-audit-scripts/workstation_audit.ps1 index fbcaa03..1bfa404 100644 --- a/projects/msp-tools/msp-audit-scripts/workstation_audit.ps1 +++ b/projects/msp-tools/msp-audit-scripts/workstation_audit.ps1 @@ -15,7 +15,7 @@ # never rename without bumping Schema Version. # ============================================================ -$ScriptVersion = "2.0.1" +$ScriptVersion = "2.0.2" $ScriptSchemaVersion = "2.0" $ScriptBuildDate = "2026-04-17" @@ -1969,11 +1969,12 @@ try { $net.EstablishedOutbound = $established } catch { $net.EstablishedOutboundError = $_.Exception.Message; $net.EstablishedOutbound = @() } - # HOSTS file + # HOSTS file (read via .NET to avoid PSObject metadata baggage in Get-Content output; + # Get-Content lines carry PSDrive/Provider reflection refs that ConvertTo-Json explodes into 40+ MB) try { $hostsPath = "$env:windir\System32\drivers\etc\hosts" - $hostsContent = Get-Content $hostsPath -ErrorAction SilentlyContinue - $hostsActive = @($hostsContent | Where-Object { $_ -and ($_ -notmatch '^\s*#') -and ($_.Trim() -ne '') }) + $hostsLines = if (Test-Path $hostsPath) { [System.IO.File]::ReadAllLines($hostsPath) } else { @() } + $hostsActive = @($hostsLines | Where-Object { $_ -and ($_ -notmatch '^\s*#') -and ($_.Trim() -ne '') } | ForEach-Object { [string]$_ }) $net.HostsFile = [ordered]@{ ActiveEntryCount = $hostsActive.Count ActiveEntries = $hostsActive