I'm trying to remove all print-server-hosted printer connections from both computer and user contexts so Group Policy Preferences can manage the replacement queues. Some printers were deployed through older Group Policy printer deployment, while others use Group Policy Preferences.
Computer-context queues can be removed with commands such as `rundll32.exe printui.dll,PrintUIEntry /gd /n"\PRINTSERVERPRINTER"`, but user-context queues often return Access Denied because they must be removed within the affected user's profile. I'm looking for a reliable PowerShell or Group Policy approach that removes legacy network printer connections without requiring users to manually click Remove.
4 Answers
You can also create a temporary printer preference item with the action set to Delete. Put the deletion item ahead of the policies that create or update printers, and choose whether it should run once or at every logon. Running it in both user and computer context may be necessary, depending on how the original queues were deployed.
If the connections follow a recognizable naming pattern, filter them before removing them. For example: `Get-Printer | Where-Object { $_.PortName -like 'IP_10.*' } | Remove-Printer -Confirm:$false`. You can separately remove matching ports with `Get-PrinterPort` and `Remove-PrinterPort`, but be careful not to delete ports still used by valid queues.
Run the cleanup in the user context, such as a logon script assigned through Group Policy. A basic approach is `Get-Printer | Where-Object { $_.Type -eq 'Connection' } | Remove-Printer -Confirm:$false`. A computer or SYSTEM script generally cannot remove printer connections that belong to a specific user profile.
That distinction is important: the script only sees printers available to the account or context running it. User connections need to be handled while that user is logged on.
For a controlled migration, rename the replacement queues or give them a temporary suffix, deploy them first, then remove the old queues gradually. This avoids disrupting users and gives you time to handle profiles where policy-based deletion is blocked.

Be aware that this can still produce Access Denied if the deletion runs in the wrong context. The policy must match the context that owns the printer connection.