fixed restore inf driver
This commit is contained in:
parent
5f67657eb7
commit
ddfe77154a
|
|
@ -187,9 +187,14 @@ function Get-PrinterDriverDetails {
|
||||||
$driverInfo.PrintProcessor = $driver.PrintProcessor
|
$driverInfo.PrintProcessor = $driver.PrintProcessor
|
||||||
|
|
||||||
# Paketverzeichnis aus INF-Pfad ableiten
|
# Paketverzeichnis aus INF-Pfad ableiten
|
||||||
|
# System-INFs wie delegwiz.inf ausfiltern - das sind keine echten Treiber-INFs
|
||||||
|
$systemInfs = @('delegwiz.inf', 'ntprint.inf', 'prnms001.inf', 'prnms002.inf')
|
||||||
if ($driver.InfPath -and (Test-Path $driver.InfPath)) {
|
if ($driver.InfPath -and (Test-Path $driver.InfPath)) {
|
||||||
|
$infName = Split-Path -Leaf $driver.InfPath
|
||||||
|
if ($systemInfs -notcontains $infName.ToLower()) {
|
||||||
$driverInfo.PackageDirectory = Split-Path -Parent $driver.InfPath
|
$driverInfo.PackageDirectory = Split-Path -Parent $driver.InfPath
|
||||||
$driverInfo.InfFileName = Split-Path -Leaf $driver.InfPath
|
$driverInfo.InfFileName = $infName
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Einzelne Treiberdateien sammeln
|
# Einzelne Treiberdateien sammeln
|
||||||
|
|
@ -593,10 +598,12 @@ function Restore-PrinterDriver {
|
||||||
|
|
||||||
# Treiber-Backup-Verzeichnis finden
|
# Treiber-Backup-Verzeichnis finden
|
||||||
$safeDirName = $driverName -replace '[\\/:*?"<>|]', '_'
|
$safeDirName = $driverName -replace '[\\/:*?"<>|]', '_'
|
||||||
$driverBackupDir = Join-Path $BackupTempDir "drivers" $safeDirName
|
$driversBaseDir = Join-Path $BackupTempDir "drivers"
|
||||||
|
$driverBackupDir = Join-Path $driversBaseDir $safeDirName
|
||||||
|
|
||||||
if (-not (Test-Path $driverBackupDir)) {
|
if (-not (Test-Path -LiteralPath $driverBackupDir)) {
|
||||||
Write-Log " Fehler: Treiberdateien fuer '$driverName' nicht in der Sicherung!" "ERROR"
|
Write-Log " Fehler: Treiberdateien fuer '$driverName' nicht in der Sicherung!" "ERROR"
|
||||||
|
Write-Log " Gesucht in: $driverBackupDir"
|
||||||
Write-Log " -> Bitte installieren Sie den Treiber manuell."
|
Write-Log " -> Bitte installieren Sie den Treiber manuell."
|
||||||
return $false
|
return $false
|
||||||
}
|
}
|
||||||
|
|
@ -604,18 +611,22 @@ function Restore-PrinterDriver {
|
||||||
# Methode 1: INF-basierte Installation (bevorzugt)
|
# Methode 1: INF-basierte Installation (bevorzugt)
|
||||||
$infPath = $null
|
$infPath = $null
|
||||||
|
|
||||||
|
# Zuerst die gespeicherte INF-Datei aus dem Backup verwenden
|
||||||
if ($DriverData.BackupInfPath) {
|
if ($DriverData.BackupInfPath) {
|
||||||
$testInf = Join-Path $driverBackupDir $DriverData.BackupInfPath
|
$testInf = Join-Path $driverBackupDir $DriverData.BackupInfPath
|
||||||
if (Test-Path $testInf) {
|
if (Test-Path -LiteralPath $testInf) {
|
||||||
$infPath = $testInf
|
$infPath = $testInf
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# INF-Datei im Backup suchen falls nicht gefunden
|
# INF-Datei im Backup suchen falls nicht gefunden
|
||||||
|
# System-INFs wie delegwiz.inf, ntprint.inf etc. ausfiltern
|
||||||
if (-not $infPath) {
|
if (-not $infPath) {
|
||||||
$infFiles = Get-ChildItem -Path $driverBackupDir -Filter "*.inf" -Recurse -ErrorAction SilentlyContinue
|
$systemInfs = @('delegwiz.inf', 'ntprint.inf', 'prnms001.inf', 'prnms002.inf')
|
||||||
|
$infFiles = Get-ChildItem -LiteralPath $driverBackupDir -Filter "*.inf" -Recurse -ErrorAction SilentlyContinue |
|
||||||
|
Where-Object { $systemInfs -notcontains $_.Name.ToLower() }
|
||||||
if ($infFiles) {
|
if ($infFiles) {
|
||||||
$infPath = $infFiles[0].FullName
|
$infPath = @($infFiles)[0].FullName
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue