Creating a printer pool

I need to create a printer pool using automation.

There are no cmdlets to create a printer pool but there appears to be a useful method in Win32_Printer class to add a connection. BUt I can't get it to work.

Any clues?

  • Can you post what you have tried?
    Or at minimum explain what you mean by 'But I can't get it to work'. Also, what OS / PowerShell version are your using?

    All that out of the way...

    Using this is not really different than using any one WMI / CIM class.

    If you dig at the class. You'll see there is no setting property for this.

    This is also true for the other printer classes

    Get-CimInstance -ClassName Win32_Printer | Get-Member
    Get-CimInstance -ClassName Win32_Printer | Select-Object -Property *

    # Choose a printer to look at its properties and values
    (Get-CimInstance -ClassName Win32_Printer | Select-Object -Property *)[5]


    So, you have to go another route.

     In this case using rundll32 printui.dll,PrintUIEntry
     

    This doc had the details
     
    'download.microsoft.com/download/8/2/c/82cffcfa-56f6-4fc3-bfa5-80cd84793871/PrintUIUsersGuide.doc
    '
    but it is no longer there.

    However, you can get to all the command info by just doing...

    rundll32 printui.dll,PrintUIEntry

    So, the option is to look thru and potentially convert the built-in *prn*.vbs files to PowerShell...


    Get-ChildItem -Path "$env:windir" -Filter '*prn*.vbs' -Recurse -ErrorAction SilentlyContinue

    Directory: C:\WINDOWS\System32\Printing_Admin_Scripts\en-US


    Mode                LastWriteTime         Length Name                                                                                      
    ----                -------------         ------ ----                                                                                      
    -a----  Sat 16 Jul 2016     07:13         105940 prncnfg.vbs                                                                               
    -a----  Sat 16 Jul 2016     07:13          51312 prndrvr.vbs                                                                               
    -a----  Sat 16 Jul 2016     07:13          69882 prnjobs.vbs                                                                               
    -a----  Sat 16 Jul 2016     07:13          81048 prnmngr.vbs                                                                               
    -a----  Sat 16 Jul 2016     07:13          56756 prnport.vbs                                                                               
    -a----  Sat 16 Jul 2016     07:13          51462 prnqctl.vbs                                                                               
    -a----  Sat 16 Jul 2016     07:13           7418 pubprn.vbs

    ...or just call them from PowerShell.


    Of course this stuff is in the registry as well...


    Get-PSDrive | Format-Table -AutoSize

    Name     Used (GB) Free (GB) Provider    Root               CurrentLocation
    ----     --------- --------- --------    ----               ---------------
    ...                             
    HKCR                         Registry    HKEY_CLASSES_ROOT                
    HKCU                         Registry    HKEY_CURRENT_USER                
    HKLM                         Registry    HKEY_LOCAL_MACHINE               
    HKU                          Registry    HKEY_USERS                       
    ...


    Get-ChildItem -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Print'


    So, you could manually set pooling and export the key to use in your automation code for subsequent needs.


    You can do something like..

    rundll32 printui.dll,PrintUIEntry /Xs /n "<YourPrinterName>" Portname "LPT1:,<PrinterPortName>"


    So, with the cmdlets listed on TechNet...

    'Print Management Cmdlets in Windows PowerShell'

    ...and the rundll32 approach or the *prn*.vbs. You have a few approaches;
    Just nothing canned in PowerShell specific to this request.