RDS - W2019 - Default Printer lost on session disconnect or logout/login

Mirto Morinini 96 Reputation points
2020-12-11T08:06:33.16+00:00

Greetings,

we have a major Issue we need to fix ASAP.
RDS Farm with 1 VM for Print Server, 1 VM RD Gateway, 1 VM RD Broker, 4 VM RDS Host (single collection).

Customer decided to let the users connect the printers they need, no deploy via GPO or PS Scripts.

Issue: Default Printer always changed back to a PDF Printer (not redirected, installed on RDSh). Already tried to disable Easy Print and Windows decide the Default Printer, plus do not set default client printer to be default printer in a session. Redirected Printer are not the source of issue, the same problem applies even if I connect directly to RDS Host without such option activated, and for a brand new user, after Profile is created and connect a printer from print server, setting it as default, the issue is the same.

I noticed it takes a lot of time to printers connected from print Server to appear, the Default Printer always fall back to a PDF Printer even on Session Disconnect / Reconnect!

I'm also aware we have a lot of entries on
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Providers\Client Side Rendering Print Provider
and
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Connections

I'm not sure if cleaning everything up would help to fix the issue.
Any help would be greatly appreciated!

Best Regards,

Mirto Morinini

Remote Desktop
Remote Desktop
A Microsoft app that connects remotely to computers and to virtual apps and desktops.
4,225 questions
Windows Server Printing
Windows Server Printing
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.Printing: Printer centralized deployment and management, scan and fax resources management, and document services
640 questions
0 comments No comments
{count} votes

Accepted answer
  1. Mirto Morinini 96 Reputation points
    2020-12-16T19:30:22.96+00:00

    I achieved some interesting results:

    I performed the steps mentioned above:

    • Open registry with psexec -i –s c:\windows\regedit.exe
    • Delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Providers\Client Side Rendering Print Provider" and then Re-Create it (empty)
    • Add under Client Side Rendering Print Provider "RemovePrintersAtLogoff" / 00000000
    • Export HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\SWD\PRINTENUM\PrintQueues , delete PRINTENUM Key it, then re-create it, then Import again all the Exported Items of PrintQueues
    • Do the same step for HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Enum\SWD\PRINTENUM and HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum\SWD\PRINTENU
    • Restart the Server

    After this, I finally got rid of all the odd registry entries that were coming back and ghost printers. I logged via RDweb with a User, connected a printer from print server, set it as default. Logged out, Logged in --> Standard Printer OK

    I did the same by re-logging to RDweb, Logging in, and the Standard Printer was still ok!

    I believed that finally this hell was over, but there is still the major issue: if the User make a proper Logoff/Login, everything is fine.
    But if the User just disconnect the session, and then reconnect, the standard printer is lost again. I really have no clues what RDS Protocol is doing and I've really no clues why on session disconnect/reconnect he's running again a "scan" of all printers, that it takes a few minutes before they appear on Printer and devices in control panel or in System Configuration GUI.

    It's already a good improvement, and I think if nothing else can be found, i'll just force a logout by disconnecting to make sure the Standard Printer will be kept.

    But I'd really like to find a fix for this. It doesn't make any sense that a user cannot disconnect/reconnect to a session and loosing the Standard printer this way.

    Any further help will be greatly appreciated, thanks!

    Edit 30.12.2020: One day after I posted this, actually I wasn't able to reproduce the issue anymore. Restarting all RDSH and the Broker, and setting a daily task to stop the spooler, delete print queues, start the spooler at night, solved actually the issue. Standard Printer don't get lost anymore with disconnect/reconnect. I've done the same operation on the RDS Prod collection and achieved the same positive result.


8 additional answers

Sort by: Most helpful
  1. Karlie Weng 13,951 Reputation points Microsoft Vendor
    2020-12-14T05:35:31.763+00:00

    Hello @Mirto Morinini

    I would recommend you first install all the available hotfixes on the Print Server.

    Then try add the following registry value :
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Providers\Client Side Rendering Print Provider\RemovePrintersAtLogoff = 0 (DWORD)

    47753-image.png

    Keep me posted how it goes. Thank you and have a great day!

    ----------

    If the Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best Regards
    Karlie

    1 person found this answer helpful.
    0 comments No comments

  2. Mirto Morinini 96 Reputation points
    2020-12-14T18:20:21.457+00:00

    Hi,

    thank you for your answer. I've cloned / sysprepped today a RDSh and made a separate collection in the way I can try to implement various solutions and avoid mess up with the productive environment.

    I've been reading a lot about such issue and how it works Printing for RDS on W2016/2019. I really don't get why Printers connected from Users are stored in HKLM..
    I've been dealing with another issue for another customer today, but this environment is using XenApp and Printers are deployed through PS Script and assigned via item-targeting (Groups/Users), it seems that issue got fixed by disabling on all shared printers "Render Print Jobs on Client Computers" and by adding the registry value you also mentioned, after deleting all sub-keys of HKLM/Client Side Rendering Print Provider on XenApp Servers.

    After some discussion with another engineering team, it looks like a similar issue of my OP was already "solved" but with a workaround that is not really a solution I would be happy to use. The issue has been identified with the fact the printers connected from users are appearing on control panel -> Printers and devices with such a great delay (minutes, not seconds, and everything is on-prem on a single hyper-v failover cluster - despite they can be seen immediately by printing from Notepad or other programs), causing the Standard Printer to be assigned to the first "physical" printer found (in this case a PDF Printer on RDSH).

    Anyway, if I add the value you suggested, I don't risk that all the printers connected from Users will disappear? As I mentioned, we are not using any GPO or PS Script to deploy printers, Users are choosing the printers they need and they must not disappear. We are using FSLogix Profiles so everything except redirected folders is stored in FSLogix Profiles.

    This is the workaround suggested from the Engineering team, maybe could inspire new suggestions..

    • Logout all Users
    • Open registry with psexec -i –s c:\windows\regedit.exe
    • Delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Providers\Client Side Rendering Print Provider" and then Re-Create it (empty)
    • Add under Client Side Rendering Print Provider "RemovePrintersAtLogoff" / 00000000
    • Export HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\SWD\PRINTENUM\PrintQueues , delete PRINTENUM Key it, then re-create it, then Import again all the Exported Items of PrintQueues
    • Do the same step for HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Enum\SWD\PRINTENUM and HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum\SWD\PRINTENU
    • Restart the Server

    Now, every Shared Printer on Print Server must be opened as security group (Ok, with AD Toolset / PS Scripts can do it relatively quickly, but..) and the description must match exactly the name of the shared printer.

    Configure this Powershell Script on Logon:

    $adsearch = "OU=PrinterMapping,OU=Groups,OU=VA,DC=contoso,DC=local"
    $adsearchdef = "OU=PrinterDefault,OU=Groups,OU=VA,DC=contoso,DC=local"
    $psrv = "PRNT-SRV01"
    
    Foreach($NetworkPrinter in $NetworkPrinters)             { 
                    $NetworkPrinter.Delete()   
                } 
    
    $pgrp = (Get-ADGroup -filter * -Searchbase $adsearch).name
    
    foreach ($g in $pgrp) { 
        $groupmember = (Get-ADGroupMember $g -Recursive).samAccountName
        foreach ($i in $groupmember) { 
    
            if($i -eq $env:USERNAME){ 
                $gdesc = (get-adgroup $g -Properties Description).Description
             $printer = get-printer -ComputerName $psrv -Name $gdesc
    
             foreach ($p in $printer) { 
    
                    add-printer -connectionname "\\$($psrv)\$($p.name)"    
                }
            }
        }
    }
    
    $pgrp = (Get-ADGroup -filter * -Searchbase $adsearchdef).name
    foreach ($g in $pgrp) { 
        $groupmember = (Get-ADGroupMember $g -Recursive).samAccountName
        foreach ($i in $groupmember) { 
    
            if($i -eq $env:USERNAME){ 
                $gdesc = (get-adgroup $g -Properties Description).Description
                $defprinter = Get-WmiObject -Query "Select * from Win32_Printer Where ShareName = '$gdesc'"
                $defprinter.SetDefaultPrinter()
            }
        }
    }
    

    And this one on Logoff

    Foreach($NetworkPrinter in $NetworkPrinters)             { 
                    $NetworkPrinter.Delete()   
                } 
    

    Honestly I really hope there is another way. It can't be that Microsoft is just sitting and doing nothing, no wonder there are so many 3th party Print Server software. I don't think I'm asking so much, I just want that my users can connect their printer and the default printer doesn't get lost every time.

    Even with this workaround I won't fix the issue permanently, as explained, the major issue is that the default printer get lost even if a user DISCONNECT the RD Session and then reconnect, the Default Print switches back to the PDF Printer, therefore there is something really wrong that is related to RDS Session - if the issue would happen only during Logout/Login I could understand and the workaround above would work, but the fact that the default printer is lost even with session disconnect/reconnect (happens with domain admin as well, global issue, so nothing about permissions) is really freaking me out.

    I will try on the testing RDSh what you suggested, maybe this will fix the issue already..but I really think I need to clean up the register properly. I also don't understand why under Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Providers\Client Side Rendering Print Provider\Servers I've 4 Print Servers listed with different Printers as well in the sub-keys. One was a test print server, but the other 3 are actually the same but with different printers.. (one is the printserver_hostname, one is printerserver_hostname.domain and the last one the IP Address of the printserver_hostname.)

    What a mess just for keeping a STANDARD PRINTER for Users.


  3. Mirto Morinini 96 Reputation points
    2020-12-16T23:14:27.713+00:00

    I was able to identify more pieces of the scrambled puzzle.
    When the Standard Printer is lost due the RDS disconnect/reconnect issue, and the user set again manually the standard printer, it seems this printer is added to

    Computer\HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum\SWD\PRINTENUM and Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\SWD\PRINTENUM

    Since there is already a printer existing in such keys, this will cause a duplicate that will cause then issues of loosing the Standard Printer even if he correctly logoff/login again and ghost printing issues.

    The only workaround that is not really a customer would appreciate, is to set in gpo (not on the colllection) to terminate a disconnected session after 1 minute. In this way this issue won't occur, but it's certainly now a solution.

    There must be another way to stop RDS to mess up printers when reconnecting.

    0 comments No comments

  4. Mirto Morinini 96 Reputation points
    2020-12-21T10:34:03.687+00:00

    FYI, I opened a Case with Microsoft business support. I'll let you know the outcome.