Remove Mapped Network Printers for all Domain Workstations with a script

We recently deployed newly named network printers using Group Policy. We would like to know if there is a way to remove the "old mapped network printers" that are installed using a script for all the domain workstations. We will be running the script using N-Able by selecting all the workstations we would like the printers removed from and then running the script against each of those workstations.
emconsultingAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

John SalleSenior IT Systems EngineerCommented:
If you know the name of the printers it's pretty simple.


VBS Script:
Dim objNetwork

ON ERROR RESUME NEXT
Set objNetwork = WScript.CreateObject("WScript.Network")

objNetwork.RemoveWindowsPrinterConnection "\\<Servername>\<Printer Share Name>"

Open in new window


That should attempt to remove it from the profile of the user who runs the script. Note the "ON ERROR RESUME NEXT" so you can script remove any old printers that might exist, and the script won't fail on errors.
John SalleSenior IT Systems EngineerCommented:
Made some edits because I had extra parts of the code in there that aren't needed. That's what I get for pulling pieces from different scripts I have.

One thing to note is that printer maps are profile specific. So if you have 2 user profiles on one computer you'll have to run this script for each user. It's probably easier to set the "remove printer" script to run on logon in AD instead of trying to push it via an RMM.
Chris MorrisCommented:
I found this link which you should be able to push out to all your clients machines.

https://gallery.technet.microsoft.com/scriptcenter/How-to-remove-all-network-f3816c96

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Spike99On-Site IT TechnicianCommented:
If you want to just remove ALL printer connections to the print server, those are stored in each user's profile in the registry under this key:

HKEY_CURRENT_USER\Printers\Connections

You can delete that "Connections" key by running this in a batch file at logon:
reg delete HKCU\Printers\Connections /f

Open in new window


The connections key will be recreated if any more printers are added to the user's profile, so it's OK to remove.
emconsultingAuthor Commented:
We were able to use a script to resolve this issue. Thank you.
hdhondtCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Printers and Scanners

From novice to tech pro — start learning today.