Delete all virtual printers

Hi,

A lot of our users have complained about virtual printers on our Windows 10. Users connect remotely and printers that are installed locally are mapped as virtual printers BUT, when they log in several times the previous virtual printers are not replaced by the new one but an extra virtual printer is created.

I'm trying to write a powershell script that every user can execute from desktop so all the virtual printers get deleted and the VDI is restarted to map the new fresh virtual printer.

The problem is only admins can delete virtual printers. I know this is not a good way to do it but if it works it would be a great leap forward for our users?

The problem I have is that the credentials, that are right, are not accepted due to faulty parameter I guess ... anyone who knows how to fix this error?

I can't put the script in GPO because it will be executed every time a user logs in and the needed virtual printer can't be loaded

$user = "anadminusername"
$pass = "asecretpassfromthatadmin"
$sPass = ConvertTo-SecureString $pass -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential($user,$sPass)
$objPrinter = Get-WmiObject -Class Win32_Printer -Credential $cred |where{$_.name -like '*Redirected*'}|where{$_.name -notlike ‘Microsoft Print to PDF*’}| foreach{$_.delete()}
$wshell = New-Object -ComObject Wscript.Shell
$output = $wshell.Popup("Redirected printers deleted. To load the new fresh virtual printer we have to restart the computer, do you want to do this now?",0,"Restart",4+32)
switch($output){
  6{Restart-Computer -Force}
  7{exit}
  default{exit}
}