How can I maintain printer information for my domain?

A. A. Below is a scipt which will go through the servers you choose in the domain and will dynamically query the servers via ADSI to get the ShareName, PrintDriver, Comment, PrinterPort (IPA, etc...), and PrinterStatus. This script was written by Aaron Shepherd.

Here is the script, in ASP:

&lt;%<br>
sub DisplayPrinterForServer(ServerToDisplay)<br>
	dim member, bstrFilter<br>
	dim PrintQObj, PrintQClass, computerName<br>
	dim item, property<br>
	dim aStr, domainMembers, computer, computerFilter<br><br>
	computerName = ServerToDisplay<br>
	set bstrNS = getObject("WinNT://" &amp; computerName)<br><br>
	'response.write bstrNS.Name &amp; ": " &amp; bstrNS.class &amp; "&lt;br&gt;"<br><br>
	bstrFilter = array("PrintQueue")<br>
	bstrNS.Filter = bstrFilter<br><br>
	response.write "&lt;big&gt;&lt;big&gt;&lt;b&gt;Printers available at: " &amp; bstrNS.Name<br>
&amp; "&lt;/b&gt;&lt;/big&gt;&lt;/big&gt;&lt;p&gt;"<br><br>
	response.write "&lt;table border=""1"" width=""100%""<br>
align=""center""&gt;"<br>
	response.write<br>
"&lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;big&gt;ShareName:&lt;/big&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;&lt;b&gt;&lt;big&gt;Print<br>
Driver:&lt;/big&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;&lt;b&gt;&lt;big&gt;Comment:&lt;/big&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;&lt;b&gt;&lt;big&gt;Port:&lt;/<br>
big&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;&lt;b&gt;&lt;big&gt;Status:&lt;/big&gt;&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;"<br><br>
	response.write "&lt;tr&gt;"<br>
	for each member in bstrNS<br>
		response.write "&lt;td width=""15%""&gt;&lt;b&gt;" &amp; Member.name &amp;<br>
"&lt;/b&gt;&lt;/td&gt;&lt;td width=""25%""&gt; " &amp; member.model &amp; "&lt;/td&gt;"<br>
		response.write "&lt;td width=""25%""&gt;" &amp; Member.description &amp;<br>
"&amp;nbsp&lt;/td&gt;&lt;td width=""20%""&gt;" &amp; Member.PrintDevices &amp; "&lt;/td&gt;"<br><br>
		response.write "&lt;td width=""15%""&gt;"<br>
		if (Member.Status and &amp;H00000000) &lt;&gt; 0 then<br>
			response.write "&lt;b&gt;"<br>
		end if<br><br>
		select case Member.Status<br>
			case &amp;H00000000:   response.write "OK"<br>
			case &amp;H00000001:   response.write "Paused"<br>
			case &amp;H00000002:   response.write "Pending Deletion"<br>
			case else:   response.write "Unknown: " &amp;<br>
Member.Status<br>
		end select<br><br>
		if (Member.Status and &amp;H00000000) &lt;&gt; 0 then<br>
			response.write "&lt;/b&gt;"<br>
		end if<br>
		response.write "&lt;/td&gt;"<br><br>
		response.write "&lt;/tr&gt;"<br>
	next<br><br>
	response.write "&lt;/table&gt;"<br>
end sub<br><br>
'You will need to adjust depending on the number of servers you are<br>
querying.  It takes 600 seconds for 20 servers<br>
Server.ScriptTimeOut = 700<br><br>
response.write "&lt;big&gt;&lt;big&gt;&lt;big&gt;&lt;b&gt;Printer Queues on Servers in<br>
YourDomain&lt;/b&gt;&lt;/big&gt;&lt;/big&gt;&lt;/big&gt;&lt;hr&gt;&lt;br&gt;&lt;b&gt;Note this will take 5 minutes to<br>
load and you will be notified when it is done.&lt;/b&gt;&lt;br&gt;&lt;br&gt;"<br><br>
DisplayPrinterForServer("server1")<br>
DisplayPrinterForServer("server2")<br>
DisplayPrinterForServer("server3")<br>
DisplayPrinterForServer("server4")<br>
DisplayPrinterForServer("server5")<br>
DisplayPrinterForServer("server6")<br>
DisplayPrinterForServer("server7")<br>
DisplayPrinterForServer("server8")<br><br><br>
response.write "&lt;br&gt;Completed ASP processing:"<br>
%&gt;

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish