Download the driver, place it in a folder on C:\Temp, check if there are multiple *.inf files. If there are, rename them (for example, $inf to something like C:\Windows\Temp\Ricoh\RH5050nw.inf).” Then creat a file Install_printer.ps1
$Logfile = "$($env:SystmRoot)\Temp\"
#Start logging
[string]$DateStr = (Get-Date).ToString("s").Replace(":","-") # +"_" # Easy sortable date string
Start-Transcript ("$Logfile" + $DateStr + '_Install_Printer_driver.log') -Force # Start logging
# Get the driver file. Select the first, in case there are more
$inf = Get-ChildItem -Path "$($env:SystemRoot)\Temp\Ricoh" -Recurse -Filter "*.inf" |
Where-Object Name -NotLike "Autorun.inf" |
Select-Object -First 1 |
Select-Object -ExpandProperty FullName
# Check that the inf file is the one you're looking for
Write-Host "The inf file is '$inf'" -ForegroundColor Cyan
# Install the driver
PNPUtil.exe /add-driver $inf /install
# Retrieve driver info
$DismInfo = Dism.exe /online /Get-DriverInfo /driver:$inf
# Retrieve the printer driver name
$DriverName = ( $DismInfo | Select-String -Pattern "Description" | Select-Object -Last 1 ) -split " : " |
Select-Object -Last 1
# Add driver to the list of available printers
Add-PrinterDriver -Name $DriverName -Verbose
# Add a network printer port
Add-PrinterPort -Name "TCPPort:" -PrinterHostAddress "10.1.2.3" -ErrorAction SilentlyContinue
#Add the printer
Add-Printer -DriverName $DriverName -Name $DriverName -PortName (Get-PrinterPort -Name LocalPort*).Name -Verbose
$Printer = Get-CimInstance -Class Win32_Printer -Filter "Name='Ricoh 5050nw'"
Invoke-CimMethod -InputObject $Printer -MethodName SetDefaultPrinter
# Get the driver file. Select the first, in case there are more
$inf = Get-ChildItem -Path "$($env:SystemRoot)\Temp\Ricoh" -Recurse -Filter "*.inf" |
Where-Object Name -NotLike "Autorun.inf" |
Select-Object -First 1 |
Select-Object -ExpandProperty FullName
# Check that the inf file is the one you're looking for
Write-Host "The inf file is '$inf'" -ForegroundColor Cyan
# Install the driver
PNPUtil.exe /add-driver $inf /install
# Retrieve driver info
$DismInfo = Dism.exe /online /Get-DriverInfo /driver:$inf
# Retrieve the printer driver name
$DriverName = ( $DismInfo | Select-String -Pattern "Description" | Select-Object -Last 1 ) -split " : " |
Select-Object -Last 1
# Add driver to the list of available printers
Add-PrinterDriver -Name $DriverName -Verbose
# Add a network printer port
Add-PrinterPort -Name "TCPPort:" -PrinterHostAddress "10.1.2.3" -ErrorAction SilentlyContinue
#Add the printer
Add-Printer -DriverName $DriverName -Name $DriverName -PortName (Get-PrinterPort -Name LocalPort*).Name -Verbose
$Printer = Get-CimInstance -Class Win32_Printer -Filter "Name='Ricoh 5050nw'"
Invoke-CimMethod -InputObject $Printer -MethodName SetDefaultPrinter
#Stop logging
Stop-Transcript