Author Posts

January 1, 2012 at 12:00 am

by Christopher.Ellis at 2013-03-22 08:29:47

trying to get DNS values for printers on a print server
I ran the followingcommand
get-wmiobject -class win32_printer -computer darequ001

SAMPLE BELOW, I have many more printers
Location :
Name : DARPRN002
PrinterState : 0
PrinterStatus : 3
ShareName : DARPRN002
SystemName : DAREQU001

Location :
Name : CHAPRN004
PrinterState : 0
PrinterStatus : 3
ShareName : CHAPRN004
SystemName : DAREQU001

Location :
Name : CHAPRN002
PrinterState : 0
PrinterStatus : 3
ShareName : CHAPRN002
SystemName : DAREQU001

I then ran the command with Get-member to see if I could get ip address and dns value, I did not see any values I could use

get-wmiobject -class win32_printer | Get-member

I did not get dns values or ipaddress configs

What must i query to get printer name, ip address and DNS entery?

by MasterOfTheHat at 2013-03-22 09:51:26

Run it with the "-Property *" parameter and pipe it to "Format-List *" and see if the information you need is in there:
get-wmiobject -class win32_printer -computer darequ001 -Property * | fl *

by coderaven at 2013-03-22 10:09:40

Oddly, this is something that from what know is a little more difficult depending on your approach.

To get the "Printer" information you are there. In the output from Get-WMIObject class Win32_Printer is a field "PortName". If those are TCP/IP ports, you now need to get class Win32_TCPIPPrinterPort and once you match that up using the name with the portname of the printer, you then know the IP stored in the port's "HostAddress". Once you have the IP you can get the name from DNS because the printer itself registers a name with DNS.

I hope that helps!

by Christopher.Ellis at 2013-03-22 11:07:19

I can get the Win32_TCPIPPrinterport

__GENUS : 2
__CLASS : Win32_TCPIPPrinterPort
__SUPERCLASS : CIM_ServiceAccessPoint
__DYNASTY : CIM_ManagedSystemElement
__RELPATH : Win32_TCPIPPrinterPort.Name="DARPRN008"
__PROPERTY_COUNT : 17
__DERIVATION : {CIM_ServiceAccessPoint, CIM_LogicalElement, CIM_ManagedSystemElement
__SERVER : DAREQU001
__NAMESPACE : root\cimv2
__PATH : \\DAREQU001\root\cimv2:Win32_TCPIPPrinterPort.Name="DARPRN008"
ByteCount :
Caption :
CreationClassName : Win32_TCPIPPrinterPort
Description : Standard TCP/IP Port
HostAddress : DARPRN008
InstallDate :
Name : DARPRN008
PortNumber : 9100
Protocol : 1
Queue :
SNMPCommunity :
SNMPDevIndex :
SNMPEnabled : False
Status :
SystemCreationClassName : Win32_ComputerSystem
SystemName :
Type :

__GENUS : 2
__CLASS : Win32_TCPIPPrinterPort
__SUPERCLASS : CIM_ServiceAccessPoint
__DYNASTY : CIM_ManagedSystemElement
__RELPATH : Win32_TCPIPPrinterPort.Name="DARPRN009"
__PROPERTY_COUNT : 17
__DERIVATION : {CIM_ServiceAccessPoint, CIM_LogicalElement, CIM_ManagedSystemElement
__SERVER : DAREQU001
__NAMESPACE : root\cimv2
__PATH : \\DAREQU001\root\cimv2:Win32_TCPIPPrinterPort.Name="DARPRN009"
ByteCount :
Caption :
CreationClassName : Win32_TCPIPPrinterPort
Description : Standard TCP/IP Port
HostAddress : DARPRN009
InstallDate :
Name : DARPRN009
PortNumber : 9100

How do i get the ipaddress Do I have to query the DNS server? if that is the case what is the syntax?? I feel like I am skirting around the issue and not pinpointing what I require

by coderaven at 2013-03-22 12:34:33

Looks like you put the DNS name in for the "HostAddress". I would query you DNS server for what the port has as hostaddress. If you are using PowerShell 3, you can use Resolve-DNSName.