Voor het installeren van printers die niet met univesal print werken heb ik een script gemaakt die de download van de driver en de installatie van de driver + het aanmaken van de printer voor de gebruiker gereed maakt.

param ([switch]$Silent)
<#
.NOTES
===========================================================================
Created on: 2023-12-15
Created by: Vincent van Unen
Organization: Xiphos SCALE IT
Filename: SC-RoadInstallPRinter
===========================================================================
.DESCRIPTION
Default Installing printer + drivers
#>

#region Changelog

#################################################################################
# Version History
$ScriptAuthor = "Vincent van Unen"
$ScripVersion = "0.1"
$ScriptChangeDate = "2023-12-15"
$ScriptChangeLog = ""
$ScriptCurrentUser = $env:UserName
$Getcurrentdate = get-date -Format yyyy-MM-dd
$logname = "SC-RoadInstallPRinter"
<# Change Log
[0.1] 2023-12-15 - First Setup of script
#>
#endregion Changelog

#Script functions

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 # Set Security protocol naar TLS12
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope LocalMachine -Force -WarningAction Ignore -ErrorAction Ignore
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process -Force -WarningAction Ignore -ErrorAction Ignore
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser -Force -WarningAction Ignore -ErrorAction Ignore

# Checking & Creatiglog en temp directory
$XIPMyModuleDir1 = "C:\temp" # Check of c:\temp dir bestaat mocht deze niet bestaan dan word deze aangemaakt
if(!(Test-Path -Path $XIPMyModuleDir1 )){ New-Item -ItemType directory -Path $XIPMyModuleDir1 }
$XIPMyModuleDir2 = "C:\tmp" # Check of c:\tmp dir bestaat mocht deze niet bestaan dan word deze aangemaakt
if(!(Test-Path -Path $XIPMyModuleDir2 )){ New-Item -ItemType directory -Path $XIPMyModuleDir2 }
$XIPMyModuleDir3 = "C:\log" # Check of c:\log dir bestaat mocht deze niet bestaan dan word deze aangemaakt
if(!(Test-Path -Path $XIPMyModuleDir3 )){ New-Item -ItemType directory -Path $XIPMyModuleDir3 }
cls


Function WriteToLogFile{
[CmdletBinding()]
Param(
[Parameter(Mandatory=$False)]
[ValidateSet("INFO","WARN","ERROR","FATAL","DEBUG")]
[String] $Level = "INFO",

[Parameter(Mandatory=$True)]
[string] $Message,

[Parameter(Mandatory=$False)]
[string] $logfile = "$XIPMyModuleDir3\$logname $Getcurrentdate.log"
)
if ($Message -eq " "){
Add-Content $logfile -Value " " -ErrorAction SilentlyContinue
}else{
$Date = (Get-Date).ToUniversalTime().ToString('yyyy-MM-dd HH:mm:ss.fff')
Add-Content $logfile -Value "[$date] [$Level] $Message" -ErrorAction SilentlyContinue
}
}


WriteToLogFile -Message "Curent Date = $Getcurrentdate"
WriteToLogFile -Message "Script Autor = $ScriptAuthor"
WriteToLogFile -Message "Script Version = $ScripVersion"
WriteToLogFile -Message "Script ChangeDate = $ScriptChangeDate"
WriteToLogFile -Message "Current User Running this script = $ScriptCurrentUser"




$TranscriptFile = "$XIPMyModuleDir3\$Getcurrentdate _$logname _Transcript.log"
Start-Transcript -Path $TranscriptFile





#Download file
$clnt = new-object System.Net.WebClient
#$url = "https://downloads.kyoceradocumentsolutions.com.au/drivers/Drivers/KyoceraClassicUniversal_signed.zip"
$urlfull = "https://downloads.kyoceradocumentsolutions.com.au/Drivers/KX_Driver.zip"
$url = "https://downloads.kyoceradocumentsolutions.com.au/Drivers/KyoceraClassicUniversal_signed.zip"
$file = "c:\Temp\TASKalfa.zip"
$clnt.DownloadFile($urlfull,$file)

WriteToLogFile -Message "The download url = $urlfull"
WriteToLogFile -Message "The Temp name = $file"

Expand-Archive "c:\temp\Taskalfa.zip" -DestinationPath "C:\Temp\PrinterDrivers" -Force

WriteToLogFile -Message "The printer driver is extracted"


#Install Printer
Invoke-Command {pnputil.exe -a "C:\temp\PrinterDrivers\64bit\OEMSETUP.inf" }
Add-PrinterDriver -Name "Kyocera TASKalfa 2551ci KX"


Function installprinteruser{
$XIPgetprinterdriver = Get-PrinterDriver

WriteToLogFile -Message "The printer driver = $XIPgetprinterdriver "

WriteToLogFile -Message "Start installing printer driver"

Add-PrinterPort -Name "IP_172.20.0.5_SPP" -PrinterHostAddress "172.20.0.5"
Add-PrinterPort -Name "IP_172.20.0.6_HRP" -PrinterHostAddress "172.20.0.6"
WriteToLogFile -Message "Start Sleep"
Start-Sleep 30
Add-Printer -Name "Support Printer" -PortName IP_172.20.0.5_SPP -DriverName "Kyocera TASKalfa 2551ci KX"
Add-Printer -Name "HR Printer" -PortName IP_172.20.0.6_HRP -DriverName "Kyocera TASKalfa 2551ci KX"
WriteToLogFile -Message "Printer drivers installed "


Start-Sleep 40
WriteToLogFile -Message "Start set papier size"

Set-PrintConfiguration -PrinterName "Support Printer" -Color:$true -PaperSize A4
Set-PrintConfiguration -PrinterName "HR Printer" -Color:$true -PaperSize A4

$XIPgetprinters = get-printer

WriteToLogFile -Message "the installed printers = $XIPgetprinters"

WriteToLogFile -Message "Job Finished "

}
installprinteruser

Stop-Transcript