1 2 Previous Next 16 Replies Latest reply on Sep 16, 2020 11:02 AM by joshuarupp Go to original post
      • 15. Re: Default printer is not remembered in VDI
        kvmw2130 Enthusiast
        VMware Employees



        Simple solution would be to create a batch file with below content:


        cmd.exe /c reg delete "HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows\SessionDefaultDevices" /f


        Then use this batch file on GPO logon script. This should help you...

        • 16. Re: Default printer is not remembered in VDI
          joshuarupp Novice

          So I'm not sure if anyone is still looking but here is what I am using in our production environment and don't have any issues.  When I googled searched I landed her and a few other pages and came up with an alternative solution.  I am already using a simliar method with Get-Printer/Add-Printer for persisting IP mapped printers so that's why I went this way.  I am open to any feedback or questions.  Don't be afraid to reach out.  Ok, so here we go...


          I used Dynamic Environment Manager (formerly known as UEM) to create a config file to persist the CSV file by creating a custom config file from the Config File Creation Wizard:



          ##  You can put file wherever you want to, that's just where I put it.


          Then I created 2 .ps1 files



          I put them into a directory that I created that hast other scripts I use - C:\ProgramData\vdiscripts\


          I created a Logon Task with the following:

          powershell.exe -ExecutionPolicy Bypass C:\ProgramData\vdiscripts\defaultprinterimport.ps1


          I created a Logoff Task with the following:

          powershell.exe -ExecutionPolicy Bypass C:\ProgramData\vdiscripts\defaultprinterexport.ps1


          Here is what was in each powershell script:




          Get-WmiObject -Query " SELECT * FROM Win32_Printer" | Where-Object { $_.Default -like 'True' } | Select-Object Name | Export-CSV "$env:localappdata\Microsoft\Windows\defaultprinter.csv" -NoTypeInformation




          $printer = Import-CSV "$env:localappdata\Microsoft\Windows\defaultprinter.csv"

          (New-Object -ComObject WScript.Network).SetDefaultPrinter($printer.Name)

          1 2 Previous Next