Files
claudetools/projects/msp-tools/utilities/clean_printer_ports.ps1
Howard Enos 8d975c1b44 import: ingested 160 files from C:\Users\howar\Clients
Howard's personal MSP client documentation folder imported into shared
ClaudeTools repo via /import command. Scope:

Clients (structured MSP docs under clients/<name>/docs/):
- anaise       (NEW)  - 13 files
- cascades-tucson     - 47 files merged (existing had only reports/)
- dataforth           - 18 files merged (alongside incident reports)
- instrumental-music-center - 14 files merged
- khalsa       (NEW)  - 22 files, multi-site (camden, river)
- kittle       (NEW)  - 16 files incl. fix-pdf-preview, gpo-intranet-zone
- lens-auto-brokerage (NEW) - 3 files (name matches SOPS vault)
- _client_template    - 13-file scaffold for new clients

MSP tooling (projects/msp-tools/):
- msp-audit-scripts/ - server_audit.ps1, workstation_audit.ps1, README
- utilities/         - clean_printer_ports, win11_upgrade,
                       screenconnect-toolbox-commands

Credential handling:
- Extracted 1 inline password (Anaise DESKTOP-O8GF4SD / david)
  to SOPS vault: clients/anaise/desktop-o8gf4sd.sops.yaml
- Redacted overview.md with vault reference pattern
- Scanned all 160 files for keys/tokens/connection strings -
  no other credentials found

Skipped:
- Cascades/.claude/settings.local.json (per-machine config)
- Source-root CLAUDE.md (personal, claudetools has its own)
- scripts/server_audit.ps1 and workstation_audit.ps1 at source root
  (identical duplicates of msp-audit-scripts versions)

Memory updates:
- reference_client_docs_structure.md (layout, conventions, active list)
- reference_msp_audit_scripts.md (locations, ScreenConnect 80-char rule)

Session log: session-logs/2026-04-16-howard-client-docs-import.md

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-16 19:43:58 -07:00

48 lines
1.4 KiB
PowerShell

# ==========================================
# CLEAN STALE PRINTER PORTS
# Removes unused TCP/IP ports, reports dead ones still in use
# ==========================================
$ports = Get-PrinterPort -ErrorAction SilentlyContinue |
Where-Object {
$_.PortMonitor -eq "TCPMON.DLL" -or
$_.PortMonitor -eq "Standard TCP/IP Port"
}
$printers = Get-Printer -ErrorAction SilentlyContinue
$usedPorts = @($printers | ForEach-Object { $_.PortName })
$removed = 0
$inUse = 0
$dead = 0
foreach ($port in $ports) {
$name = $port.Name
$ip = $port.PrinterHostAddress
if ($usedPorts -contains $name) {
# Port is used by a printer — test if alive
$ping = Test-Connection $ip -Count 1 -Quiet -ErrorAction SilentlyContinue
if (-not $ping) {
Write-Host "[WARN] In use but DEAD: $name ($ip)" -ForegroundColor Yellow
$dead++
}
$inUse++
} else {
# Port is orphaned — remove it
try {
Remove-PrinterPort -Name $name -ErrorAction Stop
Write-Host "[REMOVED] $name ($ip)" -ForegroundColor Green
$removed++
} catch {
Write-Host "[FAIL] $name - $($_.Exception.Message)" -ForegroundColor Red
}
}
}
Write-Host ""
Write-Host "Ports in use: $inUse"
Write-Host "Dead but in use: $dead (remove printer first)"
Write-Host "Orphans removed: $removed"