diff --git a/samy.ps1 b/samy.ps1 index 4e1cfb6..1ea692c 100644 --- a/samy.ps1 +++ b/samy.ps1 @@ -1807,66 +1807,6 @@ function Get-SamyDriverPackageUrl { return $null } -function Get-SamyDriverInfFromRepo { - [CmdletBinding()] - param( - [Parameter(Mandatory)][pscustomobject]$Profile - ) - - $url = Get-SamyDriverPackageUrl -Profile $Profile - $targetDir = Get-SamyDriverFolderForProfile -Profile $Profile - - if (-not $url) { - throw "No DriverPackageUrl or DriverPackagePath defined for profile '$($Profile.ProfileName)'." - } - - $zipPath = Join-Path $targetDir 'driver.zip' - - Write-LogHybrid "Downloading driver package for profile '$($Profile.ProfileName)' from $url" Info Printers -LogToEvent - - try { - Invoke-WebRequest -Uri $url -OutFile $zipPath -UseBasicParsing -ErrorAction Stop - } catch { - throw "Failed to download driver package from ${url}: $($_.Exception.Message)" - } - - # Extract zip - try { - Expand-Archive -Path $zipPath -DestinationPath $targetDir -Force - } catch { - throw "Failed to extract driver package '$zipPath': $($_.Exception.Message)" - } finally { - Remove-Item -Path $zipPath -ErrorAction SilentlyContinue - } - - # Decide which INF to use - $infPath = $null - - if ($Profile.PSObject.Properties.Name -contains 'DriverInfName' -and $Profile.DriverInfName) { - $candidate = Join-Path $targetDir $Profile.DriverInfName - if (Test-Path $candidate) { - $infPath = $candidate - } else { - Write-LogHybrid "DriverInfName '$($Profile.DriverInfName)' not found under '$targetDir'." Warning Printers -LogToEvent - } - } - - if (-not $infPath) { - $inf = Get-ChildItem -Path $targetDir -Recurse -Filter '*.inf' -ErrorAction SilentlyContinue | Select-Object -First 1 - if ($inf) { - $infPath = $inf.FullName - } - } - - if (-not $infPath -or -not (Test-Path $infPath)) { - throw "No INF file found in extracted driver package for profile '$($Profile.ProfileName)'." - } - - Write-LogHybrid "Using driver INF '$infPath' for profile '$($Profile.ProfileName)'." Info Printers -LogToEvent - return $infPath -} - - function Get-SamyClientListFromServer { <# @@ -2302,22 +2242,7 @@ function Ensure-SamyPrinterDriver { } } - # ----------------------------- - # 3) Optional legacy helper - # ----------------------------- - if (-not $infPath) { - if ($Profile.PSObject.Properties.Name -contains 'DriverPackageUrl' -or - $Profile.PSObject.Properties.Name -contains 'DriverPackagePath') { - - try { - $infPath = Get-SamyDriverInfFromRepo -Profile $Profile - } - catch { - Write-LogHybrid "Get-SamyDriverInfFromRepo failed: $($_.Exception.Message)" Error Printers -LogToEvent - throw - } - } - } + # ----------------------------- # 4) Still nothing? Hard fail with a clear message