🧬 WQL / PowerShell

Win32_Printer: Filtering Printers (WQL WHERE)

Shows the WQL WHERE clause syntax against Win32_Printer, starting from a LIKE '%' wildcard you customize with a real search term.

By WindowsScripting.com · 681 B
PrinterFiltered.ps1
<#
.SYNOPSIS
    WQL reference: filtering Printers with a WHERE clause (Win32_Printer).

.DESCRIPTION
    WQL supports a SQL-like WHERE clause for narrowing results. This
    starts from a LIKE '%' wildcard (matches everything) against
    Name — replace the wildcard with a real substring to filter
    for, e.g. WHERE Name LIKE '%searchterm%'.

.EXAMPLE
    .\PrinterFiltered.ps1
#>

[CmdletBinding()]
param()

$wqlQuery = "SELECT Name, DriverName, PortName, PrinterStatus FROM Win32_Printer WHERE Name LIKE '%'"

Write-Host "WQL: $wqlQuery" -ForegroundColor DarkGray
Get-CimInstance -Query $wqlQuery | Format-Table -Property Name, DriverName, PortName, PrinterStatus -AutoSize