Public/Printing/Start-PrinterDiagnostics.ps1
<#
Copyright © 2024 Integris. For internal company use only. All rights reserved. #> FUNCTION Start-PrinterDiagnostics { <# .SYNOPSIS Performs diagnostics on a specified printer. .DESCRIPTION This function performs various diagnostic tests on a specified printer, including checking the printer driver status, Print Spooler service status, stuck print jobs, and network connectivity. It returns the results of these diagnostics. .PARAMETER PrinterName Specifies the name of the printer to diagnose. .EXAMPLE Start-PrinterDiagnostics -PrinterName "Printer1" Performs diagnostics on the printer named "Printer1". .INPUTS System.String. The function accepts a string input for the printer name. .OUTPUTS System.Object[]. Returns an array of diagnostic results for the printer. .NOTES Ensure you have the necessary permissions to perform printer diagnostics. #> param ( [string]$PrinterName ) # Check the status of the printer driver $printerDriverName = Get-PrinterDriverName -Name $PrinterName # Check if the Print Spooler service is running $printSpoolerTest = Test-PrintSpooler # Check for stuck print jobs $stuckPrintJobs = Get-StuckPrintJobs -Name $PrinterName # Check printer connectivity $networkConnectivityTest = Test-PrinterNetworkConnectivity -Name $PrinterName $Results += New-Object PSObject -WarningAction SilentlyContinue -Property @{ PrinterName = $PrinterName printerDriverName = $printerDriverName printSpoolerTest = $printSpoolerTest stuckPrintJobs = $stuckPrintJobs networkConnectivityTest = $networkConnectivityTest error = $null } RETURN $Results } |