Skip to content

Get-PrinterErrorsList-Html

Print Management: HTML report of printer errors

#Requires -Version 5.1
#Requires -Modules PrintManagement

[CmdletBinding()]
Param([string]$ComputerName)

Process {
    try {
        if ([System.String]::IsNullOrWhiteSpace($ComputerName)) { $ComputerName = [System.Net.DNS]::GetHostByName('').HostName }
        $result = Get-WinEvent -LogName "Microsoft-Windows-PrintService/Operational" -ComputerName $ComputerName -MaxEvents 100 -ErrorAction Stop | Where-Object { $_.Level -ge 2 } | Select-Object TimeCreated, Id, LevelDisplayName, Message
        Write-Output ($result | ConvertTo-Html -Fragment)
    }
    catch { throw }
}

Computer to retrieve printer errors from

An interactive directory of PowerShell scripts.