Adding printer from print server

This topic contains 2 replies, has 3 voices, and was last updated by Profile photo of Boe Prox Boe Prox 3 years, 4 months ago.

  • Author
    Posts
  • #12811
    Profile photo of Nix151
    Nix151
    Participant

    Hi All,

    We are migrating to a new print server, and i am writing a script to detect a users installed printers, change the server name and re add the printers (and also set the default printer). This is to be deployed from SCCM 2012 R2

    The problem is that the deployment runs but doesn't migrate any of the printers – when run manually, the script asks for drivers to be installed for certain printers.

    Is there a way to bypass this in pwershell?

    I have already tried to get around the problem in SCCM but it hasnt worked.

    My Script is below.

    Thanks in advance for your help 🙂

    $net = New-Object -ComObject WScript.Network

    $oldqueues = Get-WmiObject -Class Win32_Printer | Where-Object ServerName -Like '\\ukhem02001*' | select Name -ExpandProperty Name

    $default = Get-WmiObject -Class Win32_Printer | Where-Object Default -EQ 'True'| select Name -ExpandProperty Name

    $default = $default.Replace("oldprintserver","newprintserver")

    foreach ($queue in $oldqueues){
    $path = $queue.Replace("oldprintserver","newprintserver")

    $net.AddWindowsPrinterConnection("$path")

    $net.RemovePrinterConnection("$queue")
    }

    $net.SetDefaultPrinter("$default")

  • #13269
    Profile photo of Mike F Robbins
    Mike F Robbins
    Participant

    Make sure the printer drivers for the specific operating system and architecture exist on the new print server, but I'm going to assume that's already been done. I'm guessing that user access control (UAC) is enabled on the client computers. More than likely the prompt is due to UAC and applying a group policy that disables "Point and Print Restrictions" on the computers should resolve the issue.

  • #13273
    Profile photo of Boe Prox
    Boe Prox
    Participant

    I did something very similar to this, but using Group Policy logon scripts and WMI to add the printers vs. a COM object. It may or may not be useful but we didn't have any issues with driver popups. But that could have also been the GPO setting that Mike mentioned.

    http://learn-powershell.net/2012/11/15/use-powershell-logon-script-to-update-printer-mappings/

You must be logged in to reply to this topic.