From ced4a444dc228528622d8c3f8dfca3ab1105247e Mon Sep 17 00:00:00 2001 From: cproudlock Date: Tue, 9 Dec 2025 14:55:07 -0500 Subject: [PATCH] Fix printer mapping to strip underscore suffix from port name Port names like 10.80.92.53_2 are now cleaned to 10.80.92.53 before sending to the API for printer lookup. Co-Authored-By: Claude --- scripts/Update-PC-CompleteAsset.ps1 | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/scripts/Update-PC-CompleteAsset.ps1 b/scripts/Update-PC-CompleteAsset.ps1 index f1a64f5..a4ea698 100644 --- a/scripts/Update-PC-CompleteAsset.ps1 +++ b/scripts/Update-PC-CompleteAsset.ps1 @@ -926,9 +926,7 @@ function Get-DefaultPrinterFQDN { Write-Host " Port Name: $portName" -ForegroundColor Gray # Check if this is a network printer (not a local/virtual printer) - # Network printer ports are: IP addresses, FQDNs, or UNC paths - # Skip local printer ports: USB*, LPT*, COM*, PORTPROMPT:, FILE:, NUL:, etc. - $localPorts = @('USB', 'LPT', 'COM', 'PORTPROMPT:', 'FILE:', 'NUL:', 'XPS', 'PDF') + $localPorts = @('USB', 'LPT', 'COM', 'PORTPROMPT:', 'FILE:', 'NUL:', 'XPS', 'PDF', 'FOXIT', 'Microsoft') $isLocalPrinter = $false foreach ($localPort in $localPorts) { @@ -943,9 +941,12 @@ function Get-DefaultPrinterFQDN { return $null } - # This appears to be a network printer (IP, FQDN, or UNC path) + # Strip anything after and including underscore (e.g., 10.80.92.53_2 -> 10.80.92.53) + $cleanPort = $portName -replace '_.*$', '' + Write-Host " [OK] Network printer detected - will send to database" -ForegroundColor Green - return $portName + Write-Host " Clean port: $cleanPort" -ForegroundColor Gray + return $cleanPort } else { Write-Host " No default printer found or no port available" -ForegroundColor Yellow return $null