How To Delete Network Shared Printer As Current User Using PSADT

Jahed Hussain 1 Reputation point
2021-09-16T16:38:27.98+00:00

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"

Thanks

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,435 questions
0 comments No comments
{count} votes