Update samy.ps1

This commit is contained in:
2025-12-05 19:35:45 -05:00
parent da8dfd2714
commit 760d9d2e5c

View File

@@ -2224,22 +2224,38 @@ function Ensure-SamyPrinterDriver {
throw "Failed to expand driver package '$localZip': $($_.Exception.Message)" throw "Failed to expand driver package '$localZip': $($_.Exception.Message)"
} }
# If we don't yet have an INF path, try to derive it from DriverInfName
# If we don't yet have an INF path, try to derive it from DriverInfName # If we don't yet have an INF path, try to derive it from DriverInfName
if (-not $infPath) { if (-not $infPath) {
if ($Profile.PSObject.Properties.Name -contains 'DriverInfName' -and $Profile.DriverInfName) { if ($Profile.PSObject.Properties.Name -contains 'DriverInfName' -and $Profile.DriverInfName) {
# 1) First try: directly under the destination root
$candidateInf = Join-Path $localDriverRoot $Profile.DriverInfName $candidateInf = Join-Path $localDriverRoot $Profile.DriverInfName
if (Test-Path $candidateInf) { if (Test-Path $candidateInf) {
$infPath = $candidateInf $infPath = $candidateInf
Write-LogHybrid "Resolved INF from package as '$infPath' using DriverInfName '$($Profile.DriverInfName)'." Info Printers -LogToEvent Write-LogHybrid "Resolved INF from package as '$infPath' using DriverInfName '$($Profile.DriverInfName)' at root." Info Printers -LogToEvent
} }
else { else {
Write-LogHybrid "Expected INF '$candidateInf' (from DriverInfName) not found after expanding package." Warning Printers -LogToEvent Write-LogHybrid "Expected INF '$candidateInf' (from DriverInfName) not found at root; searching recursively..." Warning Printers -LogToEvent
# 2) Second try: search subfolders for that INF name
$found = Get-ChildItem -Path $localDriverRoot -Recurse -Filter $Profile.DriverInfName -File -ErrorAction SilentlyContinue |
Select-Object -First 1
if ($found) {
$infPath = $found.FullName
Write-LogHybrid "Resolved INF from package as '$infPath' (found by recursive search for '$($Profile.DriverInfName)')." Info Printers -LogToEvent
}
else {
Write-LogHybrid "Could not find any '$($Profile.DriverInfName)' under '$localDriverRoot' after expanding package." Error Printers -LogToEvent
}
} }
} }
else { else {
Write-LogHybrid "DriverInfName not defined for profile '$($Profile.ProfileName)'; cannot auto-resolve INF from expanded package." Warning Printers -LogToEvent Write-LogHybrid "DriverInfName not defined for profile '$($Profile.ProfileName)'; cannot auto-resolve INF from expanded package." Warning Printers -LogToEvent
} }
} }
} }