Public/Printing/Get-PrinterDriverInfo.ps1

<#
Copyright © 2024 Integris. For internal company use only. All rights reserved.
#>


FUNCTION Get-PrinterDriverInfo {
    <#
    .SYNOPSIS
    Retrieves the driver information for a specified printer.
 
    .DESCRIPTION
    This function retrieves the driver information for a specified printer. If the printer is found, it returns the driver details. If the printer is not found, it displays an appropriate message and returns $null.
 
    .PARAMETER PrinterName
    Specifies the name of the printer for which to retrieve driver information.
 
    .EXAMPLE
    Get-PrinterDriverInfo -PrinterName "Printer1"
    Retrieves the driver information for the printer named "Printer1".
 
    .INPUTS
    System.String. The function accepts a string input for the printer name.
 
    .OUTPUTS
    System.Object. Returns the printer driver object if found, otherwise returns $null.
 
    .NOTES
    Ensure you have the necessary permissions to query printer and driver information.
    #>


    param (
        [string]$PrinterName
    )

    $printer = Get-Printer -Name $PrinterName
    if ($printer) {
        $driver = Get-PrinterDriver -Name $printer.DriverName
        return $driver
    } else {
        Write-Host "Printer '$PrinterName' not found."
        return $null
    }
}