Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function Check-PrinterDriver
- {
- <#
- .Synopsis
- This function gets the printer driver from the WMI and check if it exist and if the version is correct
- .Description
- This function read the printer driver data from Win32_PrinterDriver and check if the requested driver
- exist and has the correct version (if given)
- .Example
- Check-PrinterDriver -Name "HP Officejet Pro 8600" -Version "10.0.10586.0"
- Check if the driver for the HP Officejet Pro exist and if the version correspondents with 10.0.10586.0
- .Example
- Check-PrinterDriver -Name "DYMO LabelWriter 450"
- Check if the driver for the DYMO LabelWriter 450 exist, no matter which version
- .Parameter Name
- The name the printer driver has
- .Parameter Version
- The version of the printer driver
- .Notes
- NAME: Check-PrinterDriver
- AUTHOR: Erik van Oost
- LASTEDIT: 18/12/2015
- KEYWORDS: Printer Drivers
- .Link
- Http://blog.eastern.nl
- #Requires -Version 3.0
- #>
- Param([string[]]$name, [string[]]$version)
- if (Test-Path "HKLM:\SYSTEM\CurrentControlSet\Control\Print\Environments\Windows x64\Drivers\Version-3\$name")
- {
- if ($version -eq $null)
- {
- # only check if printerdriver exist
- return $true
- }
- else
- {
- # read version of the printerdrver
- if ((Get-PrinterDriverVersion -name $name) -eq $version)
- {
- return $true
- }
- else
- {
- return $false
- }
- }
- }
- else
- {
- return $false;
- }
- }
- Function Get-PrinterDriverVersion
- {
- <#
- .Synopsis
- This function gets the printer driver version from the WMI
- .Description
- This function read the printer driver data from Win32_PrinterDriver and collects the corresponding driver version
- .Example
- Get-PrinterDriverVersion -Name "HP Officejet Pro 8600"
- Returns the driver version of the HP Officejet Pro 8600 printer
- .Parameter Name
- The name the printer driver has
- .Notes
- NAME: Get-PrinterDriverVersion
- AUTHOR: Erik van Oost
- LASTEDIT: 18/12/2015
- KEYWORDS: Printer Drivers
- .Link
- Http://blog.eastern.nl
- #Requires -Version 3.0
- #>
- Param([string[]]$name)
- $driverinfo = Get-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Control\Print\Environments\Windows x64\Drivers\Version-3\$name" -ErrorAction sil
- return $driverinfo.DriverVersion
- }
- Check-PrinterDriver -name "HP Officejet Pro 8600" -version 9.84.0.1189 -Verbose
- Check-PrinterDriver -name "HP Officejet Pro 8600"
- Check-PrinterDriver -Name "DYMO LabelWriter 450"
- Get-PrinterDriverVersion -name "DYMO LabelWriter 450"
- Get-PrinterDriverVersion -name "HP Officejet Pro 8600"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement