通过 Powershell 获取打印机 SN?

通过 Powershell 获取打印机 SN?

是否可以通过 Powershell 命令获取 AD 中的网络打印机的序列号?

我在 AD 中拥有几台 Brother 打印机以及它们的 IP 地址,我可以在我的电脑上安装任何打印机并查看驱动程序,但是是否有一个 Powershell 命令可以在其中“输入”IP 地址并获取 SN 而无需安装它?

谢谢

答案1

您只能获取操作系统提供的信息,或者驱动程序制造商通过操作系统公开的信息,无论是使用提供商的工具/应用程序还是界面。

这是所有可用于检查打印机信息的内容,并且序列号不在属性选项中。

https://docs.microsoft.com/en-us/windows/win32/cimwin32prov/win32-printer

# Getting Printer Information

Get-Command -Name '*printer*'
Find-Script -Name '*printer*'
Find-Module -Name '*printer*'

(Get-CimInstance -Class Win32_Printer).Name
(Get-CimInstance -Class Win32_Printer)[6] | 
Get-Member

($PrinterName = ((Get-CimInstance -Class Win32_Printer)[6]).Name)

Get-Printer -Name $PrinterName | 
Get-Member | 
Select-Object -Property Name, MemberType

Get-PrinterPort -ComputerName $env:COMPUTERNAME

Get-PrinterDriver -ComputerName $env:COMPUTERNAME | 
Select-Object -Property '*'

Get-PrinterDriver
((Get-PrinterDriver).Name)[3] | 
Select-Object -Property '*'

Get-PrinterProperty -ComputerName $env:COMPUTERNAME -PrinterName $PrinterName

(Get-PrinterProperty -ComputerName $env:COMPUTERNAME -PrinterName $PrinterName).Value

Get-PrintConfiguration -PrinterName $PrinterName | 
Get-Member | 
Select-Object -Property Name, MemberType

答案2

披露:我不是一名打印机人员。

我刚刚列出了 AD 中几台打印机的所有属性。不幸的是,我没有看到序列号是已发布的属性。所以,总的来说,我不认为你的要求是可能的——但同样,我不是专门的打印机人员。也许你的环境不同?这里有一种方法可以检查它是否是你的 AD 属性:

Get-ADObject -filter { name -eq "Brother_Printer_Name" } -Properties *

在我的环境中,这些是 AD 打印机对象上可用的方法和属性:


   TypeName: Microsoft.ActiveDirectory.Management.ADObject

Name                            MemberType            Definition
----                            ----------            ----------
Contains                        Method                bool Contains(string propertyName)
Equals                          Method                bool Equals(System.Object obj)
GetEnumerator                   Method                System.Collections.IDictionaryEnumerator GetEnumerator()
GetHashCode                     Method                int GetHashCode()
GetType                         Method                type GetType()
ToString                        Method                string ToString()
Item                            ParameterizedProperty Microsoft.ActiveDirectory.Management.ADPropertyValueCollection Item(stri…
CanonicalName                   Property              System.String CanonicalName {get;}
CN                              Property              System.String CN {get;}
Created                         Property              System.DateTime Created {get;}
createTimeStamp                 Property              System.DateTime createTimeStamp {get;}
Deleted                         Property              System.Boolean Deleted {get;}
Description                     Property              System.String Description {get;set;}
DisplayName                     Property              System.String DisplayName {get;set;}
DistinguishedName               Property              System.String DistinguishedName {get;set;}
driverName                      Property              System.String driverName {get;set;}
driverVersion                   Property              System.Int32 driverVersion {get;set;}
dSCorePropagationData           Property              Microsoft.ActiveDirectory.Management.ADPropertyValueCollection dSCorePro…
flags                           Property              System.Int32 flags {get;set;}
instanceType                    Property              System.Int32 instanceType {get;}
isDeleted                       Property              System.Boolean isDeleted {get;}
LastKnownParent                 Property              System.String LastKnownParent {get;}
location                        Property              System.String location {get;set;}
Modified                        Property              System.DateTime Modified {get;}
modifyTimeStamp                 Property              System.DateTime modifyTimeStamp {get;}
Name                            Property              System.String Name {get;}
nTSecurityDescriptor            Property              System.DirectoryServices.ActiveDirectorySecurity nTSecurityDescriptor {g…
ObjectCategory                  Property              System.String ObjectCategory {get;}
ObjectClass                     Property              System.String ObjectClass {get;set;}
ObjectGUID                      Property              System.Nullable`1[[System.Guid, System.Private.CoreLib, Version=5.0.0.0,…
portName                        Property              Microsoft.ActiveDirectory.Management.ADPropertyValueCollection portName …
printBinNames                   Property              Microsoft.ActiveDirectory.Management.ADPropertyValueCollection printBinN…
printCollate                    Property              System.Boolean printCollate {get;set;}
printColor                      Property              System.Boolean printColor {get;set;}
printDuplexSupported            Property              System.Boolean printDuplexSupported {get;set;}
printEndTime                    Property              System.Int32 printEndTime {get;set;}
printerName                     Property              System.String printerName {get;set;}
printKeepPrintedJobs            Property              System.Boolean printKeepPrintedJobs {get;set;}
printMaxResolutionSupported     Property              System.Int32 printMaxResolutionSupported {get;set;}
printMaxXExtent                 Property              System.Int32 printMaxXExtent {get;set;}
printMaxYExtent                 Property              System.Int32 printMaxYExtent {get;set;}
printMediaReady                 Property              Microsoft.ActiveDirectory.Management.ADPropertyValueCollection printMedi…
printMediaSupported             Property              Microsoft.ActiveDirectory.Management.ADPropertyValueCollection printMedi…
printMemory                     Property              System.Int32 printMemory {get;set;}
printMinXExtent                 Property              System.Int32 printMinXExtent {get;set;}
printMinYExtent                 Property              System.Int32 printMinYExtent {get;set;}
printOrientationsSupported      Property              Microsoft.ActiveDirectory.Management.ADPropertyValueCollection printOrie…
printPagesPerMinute             Property              System.Int32 printPagesPerMinute {get;set;}
printRate                       Property              System.Int32 printRate {get;set;}
printRateUnit                   Property              System.String printRateUnit {get;set;}
printShareName                  Property              Microsoft.ActiveDirectory.Management.ADPropertyValueCollection printShar…
printSpooling                   Property              System.String printSpooling {get;set;}
printStaplingSupported          Property              System.Boolean printStaplingSupported {get;set;}
printStartTime                  Property              System.Int32 printStartTime {get;set;}
priority                        Property              System.Int32 priority {get;set;}
ProtectedFromAccidentalDeletion Property              System.Boolean ProtectedFromAccidentalDeletion {get;set;}
sDRightsEffective               Property              System.Int32 sDRightsEffective {get;}
serverName                      Property              System.String serverName {get;set;}
shortServerName                 Property              System.String shortServerName {get;set;}
uNCName                         Property              System.String uNCName {get;set;}
url                             Property              Microsoft.ActiveDirectory.Management.ADPropertyValueCollection url {get;…
uSNChanged                      Property              System.Int64 uSNChanged {get;}
uSNCreated                      Property              System.Int64 uSNCreated {get;}
versionNumber                   Property              System.Int32 versionNumber {get;set;}
whenChanged                     Property              System.DateTime whenChanged {get;}
whenCreated                     Property              System.DateTime whenCreated {get;}

如果序列号是已发布的属性,那么您应该能够通过以下方式提取它:

Get-ADObject -filter { name -eq "Brother_Printer_Name" } -Properties serialNumber | Select serialNumber

相关内容