Update samy.ps1
This commit is contained in:
18
samy.ps1
18
samy.ps1
@@ -2258,13 +2258,13 @@ function Ensure-SamyPrinterDriver {
|
|||||||
# We just continue – maybe a local INF exists or will exist.
|
# We just continue – maybe a local INF exists or will exist.
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Write-LogHybrid "Driver package download failed ($statusCode) from $driverPackageUrl: $($_.Exception.Message)" Error Printers -LogToEvent
|
Write-LogHybrid "Driver package download failed ($statusCode) from $($driverPackageUrl): $($_.Exception.Message)" Error Printers -LogToEvent
|
||||||
throw "Failed to download driver package from $driverPackageUrl: $($_.Exception.Message)"
|
throw "Failed to download driver package from $($driverPackageUrl): $($_.Exception.Message)"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
Write-LogHybrid "Driver package download failed from $driverPackageUrl: $($_.Exception.Message)" Error Printers -LogToEvent
|
Write-LogHybrid "Driver package download failed from $($driverPackageUrl): $($_.Exception.Message)" Error Printers -LogToEvent
|
||||||
throw "Failed to download driver package from $driverPackageUrl: $($_.Exception.Message)"
|
throw "Failed to download driver package from $($driverPackageUrl): $($_.Exception.Message)"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -2303,22 +2303,17 @@ function Ensure-SamyPrinterDriver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# -----------------------------
|
# -----------------------------
|
||||||
# 3) Legacy fallback: if you still want to use Get-SamyDriverInfFromRepo when we have no INF
|
# 3) Optional legacy helper
|
||||||
# (optional – keep or remove depending on whether you still use that helper)
|
|
||||||
# -----------------------------
|
# -----------------------------
|
||||||
if (-not $infPath) {
|
if (-not $infPath) {
|
||||||
if ($Profile.PSObject.Properties.Name -contains 'DriverPackageUrl' -or
|
if ($Profile.PSObject.Properties.Name -contains 'DriverPackageUrl' -or
|
||||||
$Profile.PSObject.Properties.Name -contains 'DriverPackagePath') {
|
$Profile.PSObject.Properties.Name -contains 'DriverPackagePath') {
|
||||||
|
|
||||||
# If you still have this helper and like its behavior, keep this:
|
|
||||||
try {
|
try {
|
||||||
$infPath = Get-SamyDriverInfFromRepo -Profile $Profile
|
$infPath = Get-SamyDriverInfFromRepo -Profile $Profile
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
# If that helper throws on 404, you'll still see an error, so you might choose
|
|
||||||
# to *remove* this block once you're happy with the new archive behavior.
|
|
||||||
Write-LogHybrid "Get-SamyDriverInfFromRepo failed: $($_.Exception.Message)" Error Printers -LogToEvent
|
Write-LogHybrid "Get-SamyDriverInfFromRepo failed: $($_.Exception.Message)" Error Printers -LogToEvent
|
||||||
# Re-throw or not depending on how strict you want to be:
|
|
||||||
throw
|
throw
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2333,10 +2328,8 @@ function Ensure-SamyPrinterDriver {
|
|||||||
|
|
||||||
Write-LogHybrid "Installing printer driver '$driverName' from '$infPath'." Info Printers -LogToEvent
|
Write-LogHybrid "Installing printer driver '$driverName' from '$infPath'." Info Printers -LogToEvent
|
||||||
|
|
||||||
# Install with pnputil
|
|
||||||
pnputil.exe /add-driver "`"$infPath`"" /install | Out-Null
|
pnputil.exe /add-driver "`"$infPath`"" /install | Out-Null
|
||||||
|
|
||||||
# Verify
|
|
||||||
$existingDriver = Get-PrinterDriver -Name $driverName -ErrorAction SilentlyContinue
|
$existingDriver = Get-PrinterDriver -Name $driverName -ErrorAction SilentlyContinue
|
||||||
if (-not $existingDriver) {
|
if (-not $existingDriver) {
|
||||||
throw "Failed to install printer driver '$driverName' from '$infPath'."
|
throw "Failed to install printer driver '$driverName' from '$infPath'."
|
||||||
@@ -2347,6 +2340,7 @@ function Ensure-SamyPrinterDriver {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function Install-SamyTcpIpPrinter {
|
function Install-SamyTcpIpPrinter {
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param(
|
param(
|
||||||
|
|||||||
Reference in New Issue
Block a user