Discussion:
Using WMI and Powershell to add a new printer
(too old to reply)
Janssen
2007-05-10 20:34:01 UTC
Permalink
Hello,

I'm tyring to setup a new printer on a computer using WMI and Powershell.
I'm using the following code:

$c = [WMICLASS]"root\cimv2:Win32_Printer"
$c.AddPrinterConnection("Test Printer")

This returns:



__GENUS : 2
__CLASS : __PARAMETERS
__SUPERCLASS :
__DYNASTY : __PARAMETERS
__RELPATH :
__PROPERTY_COUNT : 1
__DERIVATION : {}
__SERVER :
__NAMESPACE :
__PATH :
ReturnValue : 1801

I checked MSDN, and the return Value 1801 signifies "Invalid Name". I've
tried all different manners of strings, and tried on multiple computers, but
I always get the same return. Does anyone have any ideas on this one?

Thanks in advance.
Janssen
Janssen
2007-05-10 20:48:00 UTC
Permalink
Never mind. I now see that this is the command used to link to an existing
printer - not to create a new one.

Janssen
Post by Janssen
Hello,
I'm tyring to setup a new printer on a computer using WMI and Powershell.
$c = [WMICLASS]"root\cimv2:Win32_Printer"
$c.AddPrinterConnection("Test Printer")
__GENUS : 2
__CLASS : __PARAMETERS
__DYNASTY : __PARAMETERS
__PROPERTY_COUNT : 1
__DERIVATION : {}
ReturnValue : 1801
I checked MSDN, and the return Value 1801 signifies "Invalid Name". I've
tried all different manners of strings, and tried on multiple computers, but
I always get the same return. Does anyone have any ideas on this one?
Thanks in advance.
Janssen
Loading...