Add-Printer with Network Printer fails

Related searches

When I use Add-Printer -ConnectionName '\\server\Printer' from a local PowerShell environment it succeeds.

When I use the same command, but wrapped in an Invoke-Command like so:

Invoke-Command -ComputerName 'someServer' -Credential $creds -Authentication CredSSP -ScriptBlock { Add-Printer -ConnectionName '\\server\Printer' }

it fails saying

'\' is an invalid character.

I'm guessing it's connected to different levels of user profile being available locally vs remotely, but I'm not sure how to resolve it.

Edit: To update this, I've had to abandon this approach as I couldn't get it to work. My work-around has been to use

RUNDLL32 PRINTUI.DLL,PrintUIEntry /ga /c\\computerName /n\\someServer\Printer /q

Which works, though it does something slightly different to the Add-Printer cmdlet.

I'm not 100% sure why you're seeing that error. I'm sure it'll be something to do with how it's handling passing through the string.

However, you shouldn't really need to run it through Invoke-Command as Add-Printer has two options within itself to add printers to remote computers.

You can specify single machine with the -CompuerName parameter:

Add-Printer -ComputerName 'someServer' -ConnectionName '\\server\Printer'

You can also specify a (or multiple) CimSessions with the -CimSession parameter, allowing you to hit a bunch of machines at once.

A caveat with this command to be aware of is that it only works on Server 2012/ Windows 8 and above (including the remote target).

Fix printer connection and printing problems in Windows 10 , If you need help installing your printer in Windows 10, see Install a printer in Windows 10. If your PC is running Windows 10 S, some printers� You can also resolve the issue by the following steps: 1. Open Cortana and search for Command Prompt. Right-click the result and select Run as administrator. 2. In the Command Prompt window, type the following command and hit Enter: sc config fdphost type=own 3. Restart Windows and then re-run the

I ran into a similar problem, but I was trying to loop through a list of shared printers from a print server then add all of them to the local machine. Jump to the bottom if you want to see my solution.

The following returns all of the shared printers as objects:

$printerList = Get-Printer -ComputerName PrintServer | where Shared -eq $true

The following should have looped through all my printers and added each one:

foreach ($printer in $printerList) { 
    Add-Printer -ConnectionName "\\PrintServer\$printer.SharedName" 
}

Instead, I supposedly run into the same error as the OP:

Add-Printer : The specified server does not exist, or the server or printer name is invalid. Names may not contain ',' or '\' characters. At line:1 char:38 + ... nterList) { Add-Printer -ConnectionName "\PrintServer\$printer.SharedNam ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (MSFT_Printer:ROOT/StandardCimv2/MSFT_Printer) [Add-Printer], CimException + FullyQualifiedErrorId : HRESULT 0x80070709,Add-Printer

Needless to say, I'm very puzzled by those results because when I test what is going on, I see the following:

Write-Host $printer.ShareName
printerName

Great! Why doesn't it work in double quotes though? I am intentionally using double quotes to return the contents of the $printer variable:

Write-Host "$printer.ShareName"

MSFT_Printer (Name = "printerName", ComputerName = "PrintServer", DeviceType = 0, Type = 0).ShareName

Rather than mess with a CimException likely due to typecasting or who knows what (and yes, the ShareName property is a simple string already, it's not a hash table or a nested funky datatype of sorts), I did a simple ToString() as a workaround:

$printerList = Get-Printer -ComputerName PrintServer | where Shared -eq $true
foreach ($printer in $printerList) { 
    $printerStr = $printer.ShareName.ToString()
    Add-Printer -ConnectionName "\\PrintServer\$printerStr" 
}

What to Do if Windows Can't Connect to Your Printer, A printer can connect to a network on either an Ethernet or Wi-Fi local area fails , you can run the Windows troubleshooter to try connecting to the printer. If the printer fails to connect to the local wireless network, print a Wireless Network Test Report for assistance. Printers without a touchscreen control panel Use Wi-Fi Protected Setup (WPS) or the guided HP print driver installation to connect the printer to your local wireless network.

I ran into this issue as well ToString() didn't resolve it for me. It was the "not required" parameter -ComputerName. I was running remove-PrinterPort -Name $port, which resulted in the following error:

The specified server does not exist, or the server or printer name is invalid. Names may not contain ',' or '\' characters.

After banging my head, and Googlin', I finally added the computer name as a test like this $env:computername, I tried using a "." before, because I thought that meant local computer but, it didn't work, just stalled.

After adding the computer name, the ports, and drivers were removed without error.

get-help Remove-PrinterPort shows that -Computer name is not required but, it does seem to be required:

-ComputerName [<String>]
        Specifies the name of the computer from which to remove the printer port.

        Required?                    false
        Position?                    named
        Default value                none
        Accept pipeline input?       false
        Accept wildcard characters?  false

How to Fix the Windows Cannot Connect to Printer Error, To fix the error, first check whether the network printer is set up with a LAN port or whether the printer is connected to another system and is shared on the network. If the download fails or your printer is not listed on 123.hp.com, continue with these steps to install a driver from the HP website. Go to HP Customer Support - Software and Driver Downloads , enter your printer model if prompted, and then confirm the operating system version selected is correct.

I cannot print from the printer in a network-shared environment , To avoid this problem, make sure you install the printer driver for the client Operating System to the server Operating System first. To solve this� Step 1: Connect the printer with the Wireless Setup Wizard Most printers with a touch or text navigation control panel have a Wireless Setup Wizardtool available through the Setup, Network, or Wireless menu. Use the guided tool to select your network name and then enter the password to connect the printer to your network.

How to Troubleshoot Common Printer Problems in Windows 10, Installing drivers is a must, but if all else fails, you can run the Windows Troubleshooter to try and fix the most common printer setup problems� (In Windows 7 and earlier versions, when you click the Add Printer link, Windows will automatically search for printers on the network. The printer name(s) will pop up, and you can select one.

3. If the printer supports and has IPv6 enabled, disable IPv6 in the printer. 4. Make sure printer is plugged directly into a wall outlet and not into a UPS, power strip or surge protector. This may cause the printer to intermittently drop offline and disconnect. 5. Make sure your printer and router are at least 5 feet apart from each other. 6.

Comments
  • Add-Printer with -ComputerName returns "Parameter set cannot be resolved using the specified named parameters". When I create CimSession with New-CimSession -ComputerName 'someServer' -Credential $credentials -Authentication CredSsp I get the same error "The specified server may not exist, or the sever or printer name is invalid. Names may not contain ',' or '\' characters." But since it's a network computer it needs '\' and it worked locally...