Code:
 Function WMIGetPrinter($hostname)
$WMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" + $Hostname + "\root\cimv2")
If @Error > 0
$WMIGetPrinter = 1
Else
$Printers = $WMIService.ExecQuery("Select * from Win32_PrinterConfiguration")
If @Error > 0
$WMIGetPrinter = 1
Else
For Each $Printer in $Printers
If Left($printer.Name,2) = "\\"
? "Network Printer: " + $Printer.Name
Else
? "Local Printer: " + $Printer.Name
$LocalPrinters = $WMIService.ExecQuery("Select * from Win32_Printer where Win32_Printer.Name = '$Printername'")
For Each $LocalPrinter in $LocalPrinters
? "Location: " + $LocalPrinters.Location
? "Default: " + $LocalPrinters.Default
Next
EndIf
Next
?
$WMIGetPrinter = 0
EndIf
EndIf
EndFunction