我使用下面的代码, 把当前电脑上装的能用的, 在线的, 物理的打印机列表显示, 但是有个佳能的打印机, 明明显示未链接, 但是状态却是在线, 状态信息在后面, 求大佬支招, 多谢- cls
- Get-CimInstance -ClassName Win32_Printer | Where-Object {
- $_.WorkOffline -eq $false -and # 打印机未脱机
- $_.PortName -match "^USB|LPT" -and # 保留物理端口 (USB 或 LPT)
- $_.DriverName -notmatch "PDF|Virtual" -and # 排除虚拟打印机
- $_.PrinterStatus -eq 3 # 打印机状态为就绪
- } | ForEach-Object {
- Write-Output "Online Physical Printer Name: $($_.Name)"
- }
复制代码 未连接的佳能打印机状态信息:
Status : Unknown
Name : Canon G1010 series
Caption : Canon G1010 series
Description :
InstallDate :
Availability :
ConfigManagerErrorCode :
ConfigManagerUserConfig :
CreationClassName : Win32_Printer
DeviceID : Canon G1010 series
ErrorCleared :
ErrorDescription :
LastErrorCode :
PNPDeviceID :
PowerManagementCapabilities :
PowerManagementSupported :
StatusInfo :
SystemCreationClassName : Win32_ComputerSystem
SystemName : DESKTOP-3URCFPT
AvailableJobSheets :
Capabilities : {4, 2, 3, 5}
CapabilityDescriptions : {Copies, Color, Duplex, Collate}
CharSetsSupported :
CurrentCapabilities :
CurrentCharSet :
CurrentLanguage :
CurrentMimeType :
CurrentNaturalLanguage :
CurrentPaperType :
DefaultCapabilities :
DefaultCopies :
DefaultLanguage :
DefaultMimeType :
DefaultNumberUp :
DefaultPaperType :
DetectedErrorState : 0
ErrorInformation :
HorizontalResolution : 4294967293
JobCountSinceLastReset : 0
LanguagesSupported :
MarkingTechnology :
MaxCopies :
MaxNumberUp :
MaxSizeSupported :
MimeTypesSupported :
NaturalLanguagesSupported :
PaperSizesSupported : {7, 8, 23, 22...}
PaperTypesAvailable :
PrinterStatus : 3
TimeOfLastReset :
VerticalResolution : 4294967293
Attributes : 2624
AveragePagesPerMinute : 0
Comment :
Default : False
DefaultPriority : 0
Direct : False
DoCompleteFirst : True
DriverName : Canon G1010 series
EnableBIDI : True
EnableDevQueryPrint : False
ExtendedDetectedErrorState : 0
ExtendedPrinterStatus : 2
Hidden : False
KeepPrintedJobs : False
Local : True
Location :
Network : False
Parameters :
PortName : USB005
PrinterPaperNames : {Letter 22x28cm 8.5"x11", Legal 22x36cm 8.5"x14", A5, A4...}
PrinterState : 0
PrintJobDataType : RAW
PrintProcessor : Canon G1010 series Print Processor
Priority : 1
Published : False
Queued : False
RawOnly : False
SeparatorFile :
ServerName :
Shared : False
ShareName :
SpoolEnabled : True
StartTime :
UntilTime :
WorkOffline : False
PSComputerName :
CimClass : root/cimv2:Win32_Printer
CimInstanceProperties : {Caption, Description, InstallDate, Name...}
CimSystemProperties : Microsoft.Management.Infrastructure.CimSystemProperties |