MBE
MBE

Reputation: 3

Powershell: Adding printers to printserver

I am working on a pwershell script to synchronize two printservers, one Win 2k8 (soon to be 2012) the other Win 2k12. Everything works as it should with the exception of the final for loop to install the printers on the new 2k12 printserver.

The for loop looks like below:

foreach ($printer in $sourceprinters) { 
    Add-PrinterPort -name $printer.PortName -PrinterHostAddress $printer.ip
    Add-Printer -Name $printer.Name -PortName $Printer.PortName -DriverName $printer.DriverName -Comment $printer.Comment -Shared $printer.Shared -ShareName $printer.ShareName -Location $printer.Location  
}

The port gets added no problem however I get the following error when trying to add the printer.

Add-Printer : A positional parameter cannot be found that accepts argument 'True'. At line:63 char:5 + Add-Printer -ComputerName printserver2 -Name $printer.Name -PortName $Printe ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Add-Printer], ParameterBindingException + FullyQualifiedErrorId : PositionalParameterNotFound,Add-Printer

The new printserver already has all of the drivers installed. I tried adding the computer name but that did not make any difference, based on my research all of the parameters are valid and I verified that the values being passed are of the correct type and order.

Any help troubleshooting this would be appreciated.

Upvotes: 0

Views: 1676

Answers (1)

Maximilian Burszley
Maximilian Burszley

Reputation: 19644

-Shared $printer.Shared

This is a switch, it doesn't take an argument.

Upvotes: 2

Related Questions