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 <noreply@anthropic.com>
This commit is contained in:
cproudlock
2025-12-09 14:55:07 -05:00
parent d169892362
commit ced4a444dc

View File

@@ -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