How To Delete Network Shared Printer As Current User Using PSADT

I have the following code in my PSADT to remove a printer that has been added via a print server. As we use PSADT and deploy via SCCM, it uses a system account and as a result the system account cannot see the network printer in order to delete it. I therefore need to amend the following code so that powershell can run this line of code only as the currently logged on user.

Remove-Printer -Name “\server-address\Label Printer - No10 - 3rd Floor”

I tried the following but to no avail

Execute-ProcessAsUser Remove-Printer -Name “\server-address\Label Printer - No10 - 3rd Floor”


The function “Execute-ProcessAsUser” does just that, executes a PROCESS as user.

A great example of its usage can be found in the docs - docs

Execute-ProcessAsUser -Path "$PSHOME\powershell.exe" -Parameters "-Command & { & `"C:\Test\Script.ps1`"; Exit `$LastExitCode }" -Wait
1 Like