locked
adding printer in remote machine is not working: invalid printer name RRS feed

  • Question

  • I have gone through many blogs for finding solution for this issue, but never find a solution.

    $CompName = "test.domain.com"
    $Printer = "\\122.21.10.11\PRINTER-NAME-1"
    Invoke-Command -ComputerName $CompName -Scriptblock {
    Param($p)
    (New-Object -Com Wscript.Network).AddWindowsPrinterConnection($p)
    } -ArgumentList $Printer


    I have even tried PSRemoting and tryied to execute the ps1 file from remote machine. the same script is working in local and not working remote.

    Enter-PSSession -ComputerName "testserver.testdomain.com" -Authentication Credssp -Credential Get-Credential 

    Error:

    Exception calling "AddWindowsPrinterConnection" with "1" argument(s): "The printer name is invalid. (Exception from
    HRESULT: 0x80070709)"

    If anyone can help on this will be much appreciated.


    Wednesday, August 24, 2016 7:54 AM

Answers

  • Add global printer to system

    RUNDLL32 PRINTUI.DLL,PrintUIEntry /ga /c\\PCName /n\\ServerName\printer     

    Cannot be done with remoting unless CredSSP is configured.


    \_(ツ)_/

    Thursday, August 25, 2016 5:34 AM

All replies

  • You cannot remotely add a network printer.  Use Group Policy.

    \_(ツ)_/

    Wednesday, August 24, 2016 8:10 AM
  • Can you please let me know how to use Group Policy using Powershell
    Wednesday, August 24, 2016 10:13 AM
  • Perhaps you misunderstood the answer. Don't use PowerShell. Use Group Policy instead of PowerShell.

    Also, this is not the right forum for Group Policy questions. There are other forums for Group Policy. (You can search for them.)


    -- Bill Stewart [Bill_Stewart]

    Wednesday, August 24, 2016 3:34 PM
  • Bill, I'm trying to automate adding Printer in a remote machine.

    Can you suggest any other methods/scripting for the same.

    Thursday, August 25, 2016 4:46 AM
  • Add global printer to system

    RUNDLL32 PRINTUI.DLL,PrintUIEntry /ga /c\\PCName /n\\ServerName\printer     

    Cannot be done with remoting unless CredSSP is configured.


    \_(ツ)_/

    Thursday, August 25, 2016 5:34 AM
  • CredSSP is configured. Second-hop is also not working.

    #Working without Credssp
    Invoke-Command -ComputerName remotemac.mydomain.com -ScriptBlock {Get-ChildItem C:\Users\myusername\Desktop}
    #Working with CredSSP
    Invoke-Command -ComputerName remotemac.mydomain.com -ScriptBlock {Get-ChildItem \\sharedmac\sharef} -Authentication Credssp -Credential mydomain\myusername
    #script is working, but not showing network printers
    Invoke-Command -ComputerName remotemac.mydomain.com -ScriptBlock {(New-Object -ComObject WScript.Network).EnumPrinterConnections()} -Authentication Credssp -Credential mydomain\myusername
    #Script gives error: Invalid Printer name
    $Printer = "\\172.26.30.13\SDB1-FLOOR1-B2" # i have tried this input in single, double, with and without escape character
    Invoke-Command -ComputerName remotemac.mydomain.com -ScriptBlock {Param($p)(New-Object -Com Wscript.Network).AddWindowsPrinterConnection("$p")} -ArgumentList $Printer -Authentication Credssp -Credential mydomain\myusername

    I'm totally stuck.
    I heard we can use Group Policy, is there anyway we can automate this using group policy?
    please suggest.

    Thursday, August 25, 2016 5:58 AM
  • The remote system has to be configured and allowed access tot he third system.


    \_(ツ)_/

    Thursday, August 25, 2016 6:13 AM
  • Can anyone help on this?
    Friday, August 26, 2016 5:21 AM
  • Help you with what?


    \_(ツ)_/

    Friday, August 26, 2016 5:37 AM