从Windows打印服务器轮询打印机信息

从Windows打印服务器轮询打印机信息

问题描述:

I'm trying to develop a way to pull a list of printers (names and IPs at least), from a Windows print server. I plan to use this info in an external PHP-driven status website, running on a Linux webserver, which talks to the printers individually via SNMP. The SNMP communication is already functional. I just need a way of dynamically generating the list of printers it talks to, instead of hard coding all of the IPs/DNS Hostnames.

The idea here is that I do this entirely without touching or changing the print server(s), printers, or the underlying webserver. The only thing under my control is a shared, non-administrative CPanel account.

My research so far has led me to three potential leads. I have next to no experience with any of them.

1) The PHP printer_list command, which is part of the PECL extension. At the moment our webserver does not have this extension installed, and I'd prefer not to make that request unless I know it will work for my purposes.

2) The lpstat Linux command, part of CUPS. I've tried using it per the man page and it seems to just sit there doing nothing. I don't know if this is because it's expecting a CUPS response which I figure it will not be getting from a Windows server, or if this might be a firewall issue.

3) SMB or WMI queries of some sort. I have no idea how to even begin with these.

I'd like to ask for a recommendation on where to start. This has been a very troubling project to research because 90% of search results are about people wanting to print. Another 8% are about people polling a local system for printer info. The rest are black magic and proprietary enterprise solutions.

Any insights are very much appreciated. == Matt

我正在尝试开发一种方法来提取打印机列表(至少名称和IP), Windows打印服务器。 我计划在外部PHP驱动的状态网站中使用此信息,该网站在Linux网络服务器上运行,该网络服务器通过SNMP单独与打印机通信。 SNMP通信已经正常运行。 我只需要一种动态生成它所谈到的打印机列表的方法,而不是对所有IP / DNS主机名进行硬编码。 p>

这里的想法是我完全没有接触 或更改打印服务器,打印机或底层Web服务器。 我唯一能控制的是一个共享的,非管理性的CPanel帐户。 p>

到目前为止,我的研究已经让我有三个潜在的潜在客户。 我几乎没有任何经验。 p>

1)PHP printer_list命令,它是PECL扩展的一部分。 目前我们的网络服务器没有安装此扩展程序,除非我知道它可以用于我的目的,否则我不想发出该请求。 p>

2)lpstat Linux命令, CUPS的一部分。 我已尝试在手册页中使用它,它似乎只是坐在那里什么都不做。 我不知道这是不是因为它期待CUPS响应我认为它不会从Windows服务器获得,或者这可能是防火墙问题。 p>

3)SMB 或某种WMI查询。 我不知道如何开始这些。 p>

我想问一个关于从哪里开始的建议。 这是一个非常令人不安的研究项目,因为90%的搜索结果都是关于想要打印的人。 另外8%是关于人们在本地系统中查询打印机信息的。 其余的是黑魔术和专有企业解决方案。 p>

非常感谢任何见解。 == Matt p> div>

I am using WMI effectively to fetch printer information over network using :

Select * FROM Win32_Printer

To begin:

1 - Run wbemtest from run window.

2 - Connect to any machine where you know printers are configured.

3 - There is query option, copy Select * FROM Win32_Printer

4 - Step 4 will return you table, click on Show MOF, it will provide you printer information. Viola, you are done.

5 - I have used C# ManagementObjectSearcher & ManagementObjectCollection and it is pretty straightforward and easy to use.

There are some pros and cons of using WMI. Read it online.