Share via


add-printer command powershell gives error for default users

Question

Thursday, January 26, 2017 3:53 PM

Hello,

I created a script which automatically searches for a printer on the network and installs it as a WS printer.

When I run it as an administrator, it works fine and I can print and scan.

If it is executed by a default user, it gives an error message as follows:

add-printer : Access was denied to the specified resource.

At line:1 char:1

+ add-printer -Name "iR-ADV C250P" -Location "LocatiePrinter" -DeviceUR ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : PermissionDenied: (MSFT_Printer:ROOT/StandardCimv2/MSFT_Printer) [Add-Printer], CimException

    + FullyQualifiedErrorId : HRESULT 0x80070005,Add-Printer

The line in the script which installs the printer is as follows:

add-printer -Name "iR-ADV C250P" -Location "LocatiePrinter" -DeviceURL $DEVICEURL

Where $DEVICEURL: http://192.168.55.18:80/wsd/mex

It looks as an default user has no rights to write WMI path.

How can I grant users this right so the can install te printer as an WS printer?

JFTE

All replies (9)

Thursday, January 26, 2017 4:14 PM

Hello

You can try by copy the driver files to the remote system then you can use the add-printerdriver CmdLet.  You must just first copy them

Regards, Regin Ravi


Thursday, January 26, 2017 4:27 PM

Hello

You can try by copy the driver files to the remote system then you can use the add-printerdriver CmdLet.  You must just first copy them

Regards, Regin Ravi

Hello,

I did not mention it but at the start of the script, the drivers are being copied. When I run it as an admin on the same computer, it works fine. Default users just don't have rights on the WMI objects.

JFTE

JFTE


Friday, January 27, 2017 3:52 AM

Hi JFTE,

We could refer to the following link to authorize WMI permissions to the users.
Authorize WMI users and set permissions
https://technet.microsoft.com/en-us/library/cc771551(v=ws.11).aspx

If the issue persists, we could refer to the following link to troubleshoot this issue with Process monitor.
Using Process Monitor to solve any problem, including DebugDiag
https://blogs.msdn.microsoft.com/benjaminperkins/2013/05/03/using-process-monitor-to-solve-any-problem-including-debugdiag/

Best regards

Please remember to mark the replies as answers if they help.
If you have feedback for TechNet Subscriber Support, contact [email protected].


Friday, January 27, 2017 1:29 PM

Hi JFTE,

We could refer to the following link to authorize WMI permissions to the users.
Authorize WMI users and set permissions
https://technet.microsoft.com/en-us/library/cc771551(v=ws.11).aspx

If the issue persists, we could refer to the following link to troubleshoot this issue with Process monitor.
Using Process Monitor to solve any problem, including DebugDiag
https://blogs.msdn.microsoft.com/benjaminperkins/2013/05/03/using-process-monitor-to-solve-any-problem-including-debugdiag/

Best regards

Please remember to mark the replies as answers if they help.
If you have feedback for TechNet Subscriber Support, contact [email protected].

Hello,

I assigned the testuser(and all authenticated users), full access to the root WMI namespace and everything underneath it on the test computer. Even after a reboot the testuser gets the same error message.

JFTE


Sunday, February 5, 2017 10:07 PM

Hi JFTE,

Did you get this resolved?

I assume the print driver for the device is already installed prior to calling add-printer.

I know Canon had a long standing issue releasing print drivers that are not package aware, yet digitally signed by Microsoft.  Are these the most recent drivers for the device?  Canon released new drivers due to MS016-87.

When the printer is created when powershell is in administrative security context, is the printer added using the specified name?  "iR-ADV C250P"

I always had to rename the printer after addition due to PlugNPlay naming the printer using the information set at the device.

 

Alan Morris formerly with Windows Printing Team


Monday, February 6, 2017 2:59 PM

Hi JFTE,

Did you get this resolved?

I assume the print driver for the device is already installed prior to calling add-printer.

I know Canon had a long standing issue releasing print drivers that are not package aware, yet digitally signed by Microsoft.  Are these the most recent drivers for the device?  Canon released new drivers due to MS016-87.

When the printer is created when powershell is in administrative security context, is the printer added using the specified name?  "iR-ADV C250P"

I always had to rename the printer after addition due to PlugNPlay naming the printer using the information set at the device.

 

Alan Morris formerly with Windows Printing Team

Hello,

Unfortunatly not solved yet.

I don't install the driver first.(although I said before but that was for the W7 routine in the script). When I run the add-printer command as an admin (with the same script), the printer gets installed as an WSD printer because the machine query's the url to the printer and searches the driver it already has in W10. It shows up as an printdevice and I can print to and scan from the printer.

When I run the same script as an default user after removing the printer, I get the error message:

add-printer : Access was denied to the specified resource.

At line:1 char:1

+ add-printer -Name "iR-ADV C250P" -Location "LocatiePrinter" -DeviceUR ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : PermissionDenied: (MSFT_Printer:ROOT/StandardCimv2/MSFT_Printer) [Add-Printer], CimException

    + FullyQualifiedErrorId : HRESULT 0x80070005,Add-Printer

Looks like it see's the printer and the hardware id's, but users have no rights to do the cimsession part.

JFTE


Tuesday, February 7, 2017 9:27 AM

Hi JFTE,

"Access was denied to the specified resource."

It seems that there is a permission issue.

Have you tried to troubleshoot the issue with Process Monitor?

Best regards

Please remember to mark the replies as answers if they help.
If you have feedback for TechNet Subscriber Support, contact [email protected].


Tuesday, February 7, 2017 4:30 PM

Hi JFTE,

"Access was denied to the specified resource."

It seems that there is a permission issue.

Have you tried to troubleshoot the issue with Process Monitor?

Best regards

Please remember to mark the replies as answers if they help.
If you have feedback for TechNet Subscriber Support, contact [email protected].

Hello,

I monitored with Process monitor. No strange things but a few reg keys with no access. Gave user full access to registry but same errror:

PermissionDenied: (MSFT_Printer:ROOT/StandardCimv2/MSFT_Printer) [Add-Printer], CimException

Looks like not enough rights to WMI. But as I posted earlier, I gave rights but now succes.

JFTE


Wednesday, February 8, 2017 9:09 AM

Hi JFTE,

Based on present information, I am afraid we may have to gain admin permissions to add printer.

Best regards

Please remember to mark the replies as answers if they help.
If you have feedback for TechNet Subscriber Support, contact [email protected].