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:
[IncludeFiles]
<LocalAppData>\Microsoft\Windows\defaultprinter.csv
## You can put file wherever you want to, that's just where I put it.
Then I created 2 .ps1 files
defaultprinterexport.ps1
defaultprinterimport.ps1
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:
defaultprinterexport.ps1
------------------------
Get-WmiObject -Query " SELECT * FROM Win32_Printer" | Where-Object { $_.Default -like 'True' } | Select-Object Name | Export-CSV "$env:localappdata\Microsoft\Windows\defaultprinter.csv" -NoTypeInformation
defaultprinterimport.ps1
-----------------------
$printer = Import-CSV "$env:localappdata\Microsoft\Windows\defaultprinter.csv"
(New-Object -ComObject WScript.Network).SetDefaultPrinter($printer.Name)