# Add-printer: credential fail

**URL:** <https://forums.powershell.org/t/add-printer-credential-fail/15449>\
**Category:** PowerShell Help\
**Created:** [January 1, 2021, 1:49am UTC](https://forums.powershell.org/t/add-printer-credential-fail/15449 "2021-01-01T01:49:08Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![wex76](https://avatars.discourse-cdn.com/v4/letter/w/c2a13f/32.png) [@wex76](https://forums.powershell.org/u/wex76)\
**Post date:** [January 1, 2021, 1:49am UTC](https://forums.powershell.org/t/add-printer-credential-fail/15449/1 "2021-01-01T01:49:08Z")

</div>

Hi guys,

This is my first post in this forum so i hope i am following the rules correctly.

I am trying to set up a DOMAIN B printer on DOMAIN A computer, and it doesnt work.

Code:

Add-printer -connectionname \printer-server\printer

Error:

“add-printer alternate user credentials are required to access the specified resource”

I have found no way to add my DOMAIN B credentials to the script. Also, using a wscript.shell object, the printer is not found at all.

Relevant info:

The two domains have trust relationship whereas i can connect to the printer via SMB share and suitable DOMAIN B user credentials.

PS version: 5.1

Platform: win10, 1909

&nbsp;

Any ideas?

Thanks in advance

---

<div class="post-metadata">

**Author:** ![rob-simmers](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/rob-simmers/32/1010_2.png) [@rob-simmers](https://forums.powershell.org/u/rob-simmers)\
**Post date:** [January 1, 2021, 4:35am UTC](https://forums.powershell.org/t/add-printer-credential-fail/15449/2 "2021-01-01T04:35:28Z")

</div>

If the domains are trusted, why not just give domainA user permissions to domainB printer? That is the purpose of domain trusts. Then you should be able to just run the command you have posted.

---

<div class="post-metadata">

**Author:** ![wex76](https://avatars.discourse-cdn.com/v4/letter/w/c2a13f/32.png) [@wex76](https://forums.powershell.org/u/wex76)\
**Post date:** [January 1, 2021, 9:01pm UTC](https://forums.powershell.org/t/add-printer-credential-fail/15449/3 "2021-01-01T21:01:17Z")

</div>

Hi Rob,

Thank you for your reply.

I have probably misused the term “Trust relationship”.Domain B is accessible from Domain A , but not vice versa. Users & Computers are valid only in their corresponding domain.

Do you have an idea of how to send the proper credentials to the printer?

---

<div class="post-metadata">

**Author:** ![rob-simmers](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/rob-simmers/32/1010_2.png) [@rob-simmers](https://forums.powershell.org/u/rob-simmers)\
**Post date:** [January 4, 2021, 6:34am UTC](https://forums.powershell.org/t/add-printer-credential-fail/15449/4 "2021-01-04T06:34:26Z")

</div>

That still sounds like DomainA (user domain) trusts DomainB (resource\printer domain). This still means that DomainA credentials can be given to DomainB resources.

If you do want to connect with credentials, then you would need to use WScript.Network or net use, both outlined here:

[https://social.technet.microsoft.com/Forums/Lync/en-US/c001f594-d227-4b10-becd-b3b6b1605378/using-powershell-to-connect-network-printer-with-credentials?forum=ITCG](https://social.technet.microsoft.com/Forums/Lync/en-US/c001f594-d227-4b10-becd-b3b6b1605378/using-powershell-to-connect-network-printer-with-credentials?forum=ITCG)

---

<div class="post-metadata">

**Author:** ![tonyd](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/tonyd/32/1041_2.png) [@tonyd](https://forums.powershell.org/u/tonyd)\
**Post date:** [January 4, 2021, 12:03pm UTC](https://forums.powershell.org/t/add-printer-credential-fail/15449/5 "2021-01-04T12:03:00Z")

</div>

What is the scope of this project? Are you implement for multiple hosts or just trying to find a solution for your local workstation on a one off basis?

If this is a one off, and the domains are not trusted, you can enter domain B in your stored creds. Then it should work.

If this is for multiple users in a multi domain environment, and domain b is there to provide printing solutions to domain a, I would suggest to do as Rob says and implement a trust.

My $.02

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:28pm UTC](https://forums.powershell.org/t/add-printer-credential-fail/15449/6 "2024-05-16T20:28:02Z")

</div>


