Solved

Export Printers to a list

Posted on 2007-11-30
9
23,655 Views
Last Modified: 2011-09-20
All,
I have a windows 2000 machine that has about 200 printers installed on it.  I would like to export the printer information from the machine to a spreadsheet.  The printer name and IP address would be helpful, but really the printer name is all I need on the list.  Please help.  This is an urgent request since we are taking the printer server down for some maintance
0
Comment
Question by:dbguy2626
9 Comments
 

Author Comment

by:dbguy2626
ID: 20383609
I saw this script online but wouldnt know how to modify it to do what I want it to do.  Basically all this information is great.  how do I modify this script to run on the machine and output to a file>?

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colPorts =  objWMIService.ExecQuery _
    ("Select * from Win32_TCPIPPrinterPort")

For Each objPort in colPorts
    Wscript.Echo "Description: " & objPort.Description
    Wscript.Echo "Host Address: " & objPort.HostAddress
    Wscript.Echo "Name: " & objPort.Name
    Wscript.Echo "Port Number: " & objPort.PortNumber
    Wscript.Echo "Protocol: " & objPort.Protocol
    Wscript.Echo "SNMP Community: " & objPort.SNMPCommunity
    Wscript.Echo "SNMP Dev Index: " & objPort.SnMPDevIndex
    Wscript.Echo "SNMP Enabled: " & objPort.SNMPEnabled
Next
0
 
LVL 1

Accepted Solution

by:
nbraasch earned 500 total points
ID: 20383984
put this in a file called "printers.vbs", put it at c:\printers.vbs, then open a command prompt on the machine and type "cscript c:\printers.vbs > c:\printers.txt"  Then press enter, wait for it to finish running, then open the c:\printers.txt file to confirm you have your info in there.
0
 

Expert Comment

by:GW_Techno
ID: 34095084
I tried to use the script above to accomplish the same task and all it did was display the IP address to the screen.  The Txt file was empty.   What can I add to the file to have it collect the shared printer's sharenames?
0
 

Expert Comment

by:preshomesc
ID: 34714860
I also tried the script and the command line ... not sure what GW_Techno did but mine created the printer.txt file as advertized ...

Problem is, as GW_Techno observed, ONLY the IP address was captured and recorded ... sample of output below:

Description:
Host Address:
Name: IP_192.168.1.121
Port Number:
Protocol:
SNMP Community:
SNMP Dev Index:
SNMP Enabled:
Description:
Host Address:
Name: IP_192.168.1.122
Port Number:
Protocol:
SNMP Community:
SNMP Dev Index:
SNMP Enabled:
Description:
Host Address:
Name: IP_192.168.1.123
Port Number:
Protocol:
SNMP Community:
SNMP Dev Index:
SNMP Enabled:
Description:
Host Address:
Name: IP_192.168.1.124
Port Number:
Protocol:
SNMP Community:
SNMP Dev Index:
SNMP Enabled:
Description:
Host Address:
Name: IP_192.168.1.125
Port Number:
Protocol:
SNMP Community:
SNMP Dev Index:
SNMP Enabled:

I suspect the SQL used is incomplete.

Could someone complete the script for me, please.
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Expert Comment

by:forcecorp
ID: 34718009
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems =  objWMIService.ExecQuery _
    ("Select * from Win32_Printer")

For Each objItem In colItems
Wscript.Echo "Description: " & objItem.Description
Wscript.Echo "Printer: " & objItem.DeviceID
Wscript.Echo "Driver Name: " & objItem.DriverName
Wscript.Echo "Port Name: " & objItem.PortName
Wscript.Echo "ShareName: " & objItem.ShareName
Wscript.Echo "Location: " & objItem.Location
Wscript.Echo
Wscript.Echo
Next
0
 

Expert Comment

by:preshomesc
ID: 34742038
Thank you FORCECORP!

THAT was the correct answer!
0
 

Expert Comment

by:GW_Techno
ID: 34836516
Thanks FORCECORP!  That worked perfectly
0
 

Expert Comment

by:Checkered
ID: 35083151
This script was very useful to me today.  Thanks to all who contributed!
0
 

Expert Comment

by:IMD_IS_Admins
ID: 35230229
Hello,
Thanks for the script, very useful and simple.
Here is a customized version that puts all on 1 line for each printer... easy to re-use in Excel (semicolon separated):

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems =  objWMIService.ExecQuery _
    ("Select * from Win32_Printer")

For Each objItem In colItems
Wscript.Echo "Description:" & ";" & objItem.Description & ";" & "Printer:" & ";" & objItem.DeviceID & ";" & "Driver Name:" & ";" & objItem.DriverName & ";" & "Port Name:" & ";" & objItem.PortName & ";" & "ShareName:" & ";" & objItem.ShareName & ";" & "Location:" & ";" & objItem.Location
Next

Is there a way to retrieve also other information, like some settings (trays, duplex,...) ?

Cheers

Richard
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In this article we want to have a look at the directory attributes which are used by Microsoft to store the so called Security Identifiers (SID). These SIDs plays an important role in delegating and granting permissions and in authentication of trus…
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now