7 0

Download driver and install printer

Get all printer drivers currently installed:

Get-PrinterDriver -Name *

[showhide type="kyocerapa6000" more_text="Click to show Kyocera ECOSYS PA6000x & MA6000ifx example with proxy" less_text="Kyocera ECOSYS PA6000x & MA6000ifx Driver example:"]

$PrinterName1 = "SPA8"
$PrinterName2 = "SPBR"
$DriverName1 = "Kyocera ECOSYS PA6000x KX"
$DriverName2 = "Kyocera ECOSYS MA6000ifx KX"
$PrinterIP1 = "172.26.36.95"
$PrinterIP2 = "172.26.36.106"
$printer1 = Get-Printer -Name $PrinterName1 -ErrorAction SilentlyContinue
$printer2 = Get-Printer -Name $PrinterName2 -ErrorAction SilentlyContinue
$needsInstallation = $false
if ($printer1 -and $printer1.DriverName -eq $DriverName1 -and $printer2 -and $printer2.DriverName -eq $DriverName2) {
    Write-Host "Both printers already exist with correct drivers."
    exit 0  # Success - no changes needed
} else {
    Write-Host "One or both printers need to be updated."
    $needsInstallation = $true
}
if ($needsInstallation) {
    Remove-Printer -Name $PrinterName1 -ErrorAction SilentlyContinue
    Remove-Printer -Name $PrinterName2 -ErrorAction SilentlyContinue
    $ProgressPreference = "SilentlyContinue"
    $Link = "https://dam.kyoceradocumentsolutions.com/content/dam/gdam_dc/dc_global/executables/web/Kx85_UPD_8.5.2405_en_RC2_WHQL.zip"
    $File = "Kx85_UPD_8.5.2405_en_RC2_WHQL.zip"
    $Path = "C:\Users\Public\Downloads"
    $DriverPath = "C:\PrinterDriver"
    if (Test-Path $Path\$File) {
        Remove-Item $Path\$File
    }
    Invoke-WebRequest -Uri $Link -Proxy http://proxy.ezorg.nl:8080 -ProxyUseDefaultCredentials -OutFile $Path\$File -UseBasicParsing
    if (-Not (Test-Path $DriverPath)) {
        New-Item -ItemType directory -Path $DriverPath
    }
    Expand-Archive $Path\$File $DriverPath
    cmd.exe /c "pnputil.exe -i -a C:\PrinterDriver\Kx85_UPD_8.5.2405_en_RC2_WHQL\64bit\OEMSETUP.INF"
    Add-PrinterDriver -Name $DriverName1
    Add-PrinterDriver -Name $DriverName2
    Add-PrinterPort -Name IP_$PrinterIP1 -PrinterHostAddress $PrinterIP1
    Add-PrinterPort -Name IP_$PrinterIP2 -PrinterHostAddress $PrinterIP2
    Add-Printer -Name $PrinterName1 -DriverName $DriverName1 -PortName IP_$PrinterIP1
    Add-Printer -Name $PrinterName2 -DriverName $DriverName2 -PortName IP_$PrinterIP2
    Get-Printer -full | Format-Table -AutoSize | Out-String -Width 10000
    $printer = Get-WmiObject -Query "SELECT * FROM Win32_Printer WHERE Name='$PrinterName1'"
    $printer.InvokeMethod("PrintTestPage", $null)
    $printer = Get-WmiObject -Query "SELECT * FROM Win32_Printer WHERE Name='$PrinterName2'"
    $printer.InvokeMethod("PrintTestPage", $null)
    Write-Host "Printer installation completed successfully."
    exit 0  # Success - installation completed
}

[/showhide]

[showhide type="hp" more_text="Click to show HP Color LaserJet Pro MFP 4302 Driver example" less_text="HP Universal Printing PCL 6 Driver example:"]

$DriverName = "HP Universal Printing PCL 6"
$PrinterIP = "HPIA54872"
$PrinterName = "HP Color LaserJet Pro MFP"
if(Get-PrinterDriver | Where-Object {$_.Name -like "$DriverName"}){exit}
$DriverDownload = "https://ftp.hp.com/pub/softlib/software13/printers/UPD/upd-pcl6-x64-7.3.0.25919.zip"
$ProgressPreference = "SilentlyContinue"
$DriverPath = "C:\PrinterDriver"
if(!(Test-Path "$DriverPath")){md "$DriverPath"}
if(!(Test-Path "$DriverPath\$DriverName")){md "$DriverPath\$DriverName"}
Invoke-WebRequest -Uri $DriverDownload -OutFile $DriverPath\upd-pcl6-x64-7.3.0.25919.zip -UseBasicParsing
Start-Sleep -Seconds 2
Expand-Archive $DriverPath\upd-pcl6-x64-7.3.0.25919.zip $DriverPath\$DriverName
cmd /c "pnputil -i -a `"$DriverPath\$DriverName\*.inf`""
Add-PrinterDriver -Name $DriverName
Add-PrinterPort -Name IP_$PrinterIP -PrinterHostAddress $PrinterIP
Add-Printer -Name $PrinterName -DriverName $DriverName -PortName IP_$PrinterIP
Get-Printer -full | Format-Table -AutoSize| Out-String -Width 10000

Testpagina:
Function Out-TestPage { Param([string]$printer = "HP Color LaserJet Pro MFP") Invoke-CimMethod -MethodName PrintTestPage -InputObject (Get-CimInstance Win32_Printer -Filter "name LIKE '$printer'") }
Out-TestPage

[/showhide]

[showhide type="epson" more_text="Click to show EPSON AM-C4000 Series Driver example" less_text="EPSON AM-C4000 Series Driver example:"]

if(Get-PrinterDriver | Where-Object {$_.Name -like "EPSON AM-C4000 Series"}){exit}
$DriverDownload = "https://download.epson-europe.com/pub/download/6659/epson665961eu.exe"
$ProgressPreference = "SilentlyContinue"
$DriverName = "EPSON AM-C4000 Series"
$DriverPath = "C:\PrinterDriver"
if(!(Test-Path "$DriverPath")){md "$DriverPath"}
Invoke-WebRequest -Uri $DriverDownload -OutFile $DriverPath\epson665961eu.exe -UseBasicParsing
Start-Sleep -Seconds 2
Start-Process -FilePath "C:\Program Files\7-Zip\7z.exe" -ArgumentList "x -y -o$DriverPath $DriverPath\epson665961eu.exe" -Wait
cmd.exe /c "pnputil.exe -i -a $DriverPath\AMC4000_x64_304JAUsHomeExportAsiaML\WINX64\*.inf"
Add-PrinterDriver -Name $DriverName

[/showhide]

[showhide type="lexmark" more_text="Click to show Lexmark B3442dw Printer Driver example" less_text="Lexmark B3442dw Printer Driver example:"]

Get-Printer -full | Format-Table -AutoSize| Out-String -Width 10000
$ProgressPreference = "SilentlyContinue"
$PrinterIP = "192.168.5.61"
$DriverName = "Lexmark B3400 Series HBP"
$PrinterName = "Lexmark B3442dw"
$Link = "https://downloads.lexmark.com/downloads/drivers/Lexmark_Printer_Software_G4_Installation_Package_04202023.exe"
$File = "Lexmark_Printer_Software_G4_Installation_Package_04202023.exe"
$Path = "C:\Users\Public\Downloads"
$DriverPath = "C:\PrinterDriver"

if (Test-Path $Path\$File) {
  Remove-Item $Path\$File
}
Invoke-WebRequest -Uri $Link -OutFile $Path\$File -UseBasicParsing

if (-Not (Test-Path $DriverPath)) {
  New-Item -ItemType directory -Path $DriverPath
}

Start-Process -FilePath "C:\Program Files\7-Zip\7z.exe" -ArgumentList "x -y -o$DriverPath $Path\$File" -Wait

Start-Process -FilePath "msiexec.exe" -ArgumentList "/i $DriverPath\InstallationPackage\Drivers\x64\print64HBP.msi /qn /L*v install.log" -Wait
cmd.exe /c "pnputil.exe -i -a C:\PROGRA~1\Lexmark\Lexmar~1\Drivers\Print\GDI\LMU04r40.inf"

Add-PrinterDriver -Name $DriverName
Add-PrinterPort -Name IP_$PrinterIP -PrinterHostAddress $PrinterIP
Add-Printer -Name $PrinterName -DriverName $DriverName -PortName IP_$PrinterIP
Get-Printer -full | Format-Table -AutoSize| Out-String -Width 10000

[/showhide]

[showhide type="kxproxy" more_text="Click to show KX Printer Driver 8.3 / Kyocera ECOSYS M3655idn example with proxy" less_text="KX Printer Driver 8.3 / Kyocera ECOSYS M3655idn with proxy example:"]

# Download and extract KX Printer Driver 8.3
Get-Printer -full | Format-Table -AutoSize| Out-String -Width 10000
$ProgressPreference = "SilentlyContinue"
$Link = "https://dam.kyoceradocumentsolutions.com/content/dam/gdam_dc/dc_global/executables/web/Kx83_UPD_8.3.0815_RC5_en.zip"
$File = "Kx83_UPD_8.3.0815_RC5_en.zip"
$Path = "C:\Users\Public\Downloads"
$DriverPath = "C:\PrinterDriver"
if (Test-Path $Path\$File) {
  Remove-Item $Path\$File
}
Invoke-WebRequest -Uri $Link -Proxy http://proxy.ezorg.nl:8080 -ProxyUseDefaultCredentials -OutFile $Path\$File -UseBasicParsing
if (-Not (Test-Path $DriverPath)) {
  New-Item -ItemType directory -Path $DriverPath
}
Expand-Archive $Path\$File $DriverPath

# Install KX Printer Driver 8.3
cmd.exe /c "pnputil.exe -i -a C:\PrinterDriver\Kx83_UPD_8.3.0815_RC5_en\64bit\OEMSETUP.INF"

# Install Kyocera ECOSYS M3655idn Printer
$PrinterIP = "172.1.2.3"
$DriverName = "Kyocera ECOSYS M3655idn KX"
$PrinterName1 = "Kyocera ECOSYS M3655idn A6 Recept"
$PrinterName2 = "Kyocera ECOSYS M3655idn Blanco"
$PrinterName3 = "Kyocera ECOSYS M3655idn Kwitantie"
Add-PrinterDriver -Name $DriverName
Add-PrinterPort -Name IP_$PrinterIP -PrinterHostAddress $PrinterIP
Add-Printer -Name $PrinterName1 -DriverName $DriverName -PortName IP_$PrinterIP
Add-Printer -Name $PrinterName2 -DriverName $DriverName -PortName IP_$PrinterIP
Add-Printer -Name $PrinterName3 -DriverName $DriverName -PortName IP_$PrinterIP
Get-Printer -full | Format-Table -AutoSize| Out-String -Width 10000

[/showhide]

[showhide type="kmproxy" more_text="Click to show KONICA MINOLTA bizhub Universal PCL with proxy example" less_text="KONICA MINOLTA bizhub Universal PCL with proxy example:"]

$DriverDownload = "https://link.to/driver.zip"
$ProgressPreference = "SilentlyContinue"
$PrinterIP = "192.168.210.222"
$DriverName = "KONICA MINOLTA Universal PCL"
$PrinterName = "KONICA MINOLTA bizhub C250i"

New-Item -ItemType directory -Path C:\PrinterDriver
Invoke-WebRequest -Uri $DriverDownload -Proxy http://proxy.ezorg.nl:8080 -ProxyUseDefaultCredentials -OutFile C:\PrinterDriver\UPDPCL6Win_391180MU.zip -UseBasicParsing
Start-Sleep -Seconds 2
Expand-Archive C:\PrinterDriver\UPDPCL6Win_391180MU.zip C:\PrinterDriver
cmd.exe /c "pnputil.exe -i -a C:\PrinterDriver\UPDPCL6Win_391180MU\driver\win_x64\*.inf"
Add-PrinterDriver -Name $DriverName
Add-PrinterPort -Name IP_$PrinterIP -PrinterHostAddress $PrinterIP
Add-Printer -Name $PrinterName -DriverName $DriverName -PortName IP_$PrinterIP

[/showhide]

[showhide type="kmnoproxy" more_text="Click to show KONICA MINOLTA bizhub Universal PCL" less_text="KONICA MINOLTA bizhub Universal PCL example:"]

$DriverDownload = "https://link.to/driver.zip"
$ProgressPreference = "SilentlyContinue"
$PrinterIP = "192.168.210.222"
$DriverName = "KONICA MINOLTA Universal PCL"
$PrinterName = "KONICA MINOLTA bizhub C250i"

New-Item -ItemType directory -Path C:\PrinterDriver
Invoke-WebRequest -Uri $DriverDownload -OutFile C:\PrinterDriver\UPDPCL6Win.zip -UseBasicParsing
Start-Sleep -Seconds 2
Expand-Archive C:\PrinterDriver\UPDPCL6Win.zip C:\PrinterDriver
$folderName = (Get-ChildItem -Path "C:\PrinterDriver" -Directory).Name
cmd.exe /c "pnputil.exe -i -a C:\PrinterDriver\$folderName\driver\win_x64\*.inf"
Add-PrinterDriver -Name $DriverName
Add-PrinterPort -Name IP_$PrinterIP -PrinterHostAddress $PrinterIP
Add-Printer -Name $PrinterName -DriverName $DriverName -PortName IP_$PrinterIP

[/showhide]

[showhide type="hp" more_text="Click to show HP PageWide Pro 477dw MFP PCL 6 example" less_text="HP PageWide Pro 477dw MFP PCL 6 example:"]

Get-Printer -full | Format-Table -AutoSize| Out-String -Width 10000
$ProgressPreference = "SilentlyContinue"
$Link = "https://ftp.hp.com/pub/softlib/software13/printers/PW477/Basic_Webpack_x64-38.9.2003-PW477_DW_Basicx64_Webpack.exe"
$File = "Basic_Webpack_x64-38.9.2003-PW477_DW_Basicx64_Webpack.exe"
$Path = "C:\Users\Public\Downloads"
$DriverPath = "C:\PrinterDriver"
if (Test-Path $Path\$File) {
  Remove-Item $Path\$File
}
Invoke-WebRequest -Uri $Link -OutFile $Path\$File -UseBasicParsing
if (-Not (Test-Path $DriverPath)) {
  New-Item -ItemType directory -Path $DriverPath
}
Start-Process -FilePath "C:\Program Files\7-Zip\7z.exe" -ArgumentList "x -y -oC:\PrinterDriver C:\Users\Public\Downloads\Basic_Webpack_x64-38.9.2003-PW477_DW_Basicx64_Webpack.exe" -Wait
cmd.exe /c "pnputil.exe -i -a C:\PrinterDriver\hpmaD511_x64.inf"
$PrinterIP = "HOSTNAME"
$DriverName = "HP PageWide Pro 477dw MFP PCL 6"
$PrinterName = "HP PageWide Pro 477dw"
Add-PrinterDriver -Name $DriverName
Add-PrinterPort -Name IP_$PrinterIP -PrinterHostAddress $PrinterIP
Add-Printer -Name $PrinterName -DriverName $DriverName -PortName IP_$PrinterIP
Get-Printer -full | Format-Table -AutoSize| Out-String -Width 10000

[/showhide]

[showhide type="km" more_text="Click to show KONICA MINOLTA bizhub Universal PCL example" less_text="KONICA MINOLTA bizhub Universal PCL example:"]

Get-Printer -full | Format-Table -AutoSize| Out-String -Width 10000
$ProgressPreference = "SilentlyContinue"
$PrinterIP = "192.168.3.204"
$DriverName = "KONICA MINOLTA Universal PCL"
$PrinterName = "KM bizhub C308"
$Link = "https://dl.konicaminolta.eu/nl?tx_kmdownloadcentersite_downloadproxy[fileId]=d4bd14a1e3f0617f24287d043c046bf9&tx_kmdownloadcentersite_downloadproxy[documentId]=134901&tx_kmdownloadcentersite_downloadproxy[system]=KonicaMinolta&tx_kmdownloadcentersite_downloadproxy[language]=NL&type=1558521685"
$File = "UPDPCL6Win_392200MU.zip"
$Path = "C:\Users\Public\Downloads"
$DriverPath = "C:\PrinterDriver"

if (Test-Path $Path\$File) {
  Remove-Item $Path\$File
}
Invoke-WebRequest -Uri $Link -OutFile $Path\$File -UseBasicParsing

if (-Not (Test-Path $DriverPath)) {
  New-Item -ItemType directory -Path $DriverPath
}

Start-Process -FilePath "C:\Program Files\7-Zip\7z.exe" -ArgumentList "x -y -o$DriverPath $Path\$File" -Wait

cmd.exe /c "pnputil.exe -i -a C:\PrinterDriver\UPDPCL6Win_392200MU\driver\win_x64\*.inf"

Add-PrinterDriver -Name $DriverName
Add-PrinterPort -Name IP_$PrinterIP -PrinterHostAddress $PrinterIP
Add-Printer -Name $PrinterName -DriverName $DriverName -PortName IP_$PrinterIP
Get-Printer -full | Format-Table -AutoSize| Out-String -Width 10000

[/showhide]

[showhide type="brother" more_text="Click to show Brother MFC-L9577CDW example" less_text="Brother MFC-L9577CDW example:"]

Get-Printer -full | Format-Table -AutoSize| Out-String -Width 10000
$ProgressPreference = "SilentlyContinue"
$PrinterIP = "BRNB42200394F4E"
$DriverName = "Brother MFC-L9570CDW series"
$PrinterName = "Brother MFC-L9577CDW"
$Link = "https://download.brother.com/welcome/dlf103195/Y16E_C1-hostm-F2.EXE"
$File = "Y16E_C1-hostm-F2.EXE"
$Path = "C:\Users\Public\Downloads"
$DriverPath = "C:\PrinterDriver"

if (Test-Path $Path\$File) {
  Remove-Item $Path\$File
}
Invoke-WebRequest -Uri $Link -OutFile $Path\$File -UseBasicParsing

if (-Not (Test-Path $DriverPath)) {
  New-Item -ItemType directory -Path $DriverPath
}

Start-Process -FilePath "C:\Program Files\7-Zip\7z.exe" -ArgumentList "x -y -o$DriverPath $Path\$File" -Wait

cmd.exe /c "pnputil.exe -i -a C:\PrinterDriver\gdi\BRPRC16A.INF"

Add-PrinterDriver -Name $DriverName
Add-PrinterPort -Name IP_$PrinterIP -PrinterHostAddress $PrinterIP
Add-Printer -Name $PrinterName -DriverName $DriverName -PortName IP_$PrinterIP
Get-Printer -full | Format-Table -AutoSize| Out-String -Width 10000

[/showhide]

[showhide type="brotheruniversal" more_text="Click to show Brother Universal (Black/White only) example" less_text="Brother Universal (Black/White only) example:"]

Get-Printer -full | Format-Table -AutoSize| Out-String -Width 10000
$ProgressPreference = "SilentlyContinue"
$PrinterIP = "BRNB42200394F4E"
$DriverName = "Brother PCL5e Driver"
$PrinterName = "Brother Printer"
$Link = "https://kbhost.nl/wp-content/uploads/2022/06/BrotherUniversalPCL5e.zip"
$File = "BrotherUniversalPCL5e.zip"
$Path = "C:\Users\Public\Downloads"
$DriverPath = "C:\PrinterDriver"

if (Test-Path $Path\$File) {
  Remove-Item $Path\$File
}
Invoke-WebRequest -Uri $Link -OutFile $Path\$File -UseBasicParsing

if (-Not (Test-Path $DriverPath)) {
  New-Item -ItemType directory -Path $DriverPath
}

Start-Process -FilePath "C:\Program Files\7-Zip\7z.exe" -ArgumentList "x -y -o$DriverPath $Path\$File" -Wait

cmd.exe /c "pnputil.exe -i -a C:\PrinterDriver\BrotherUniversalPCL5e\BHPCL5E.INF"

Add-PrinterDriver -Name $DriverName
Add-PrinterPort -Name IP_$PrinterIP -PrinterHostAddress $PrinterIP
Add-Printer -Name $PrinterName -DriverName $DriverName -PortName IP_$PrinterIP
Get-Printer -full | Format-Table -AutoSize| Out-String -Width 10000

[/showhide]

Print a test page:

$printer = Get-WmiObject -Query "SELECT * FROM Win32_Printer WHERE Name='$PrinterName'"
$printer.InvokeMethod("PrintTestPage", $null)

Install Shared Networkprinter (run twice):

pnputil /add-driver "\\FPS01\PTR006" /install & rundll32 printui.dll,PrintUIEntry /in /n"\\FPS01\PTR006" & powershell -Command "Add-Printer -ConnectionName '\\FPS01\PTR006'"