The code is provided by microsoft, and of course copy writed Microsoft
However, the source code is visible, and I don't know if that is close enough, but its as close as I have ever seen to open source.
However, all the real work is done with the WMI windows interface. All the scripts could be rewritten to support any language that have WMI support. I saw a WMI for linux, but the version I saw was super old and unmaintained so I won't mention it.
These scripts are provided by Microsoft free on Windows 10 and probably Windows 7. I don't know if they are available on any previous version of windows.
cscript prnmngr.vbs -u username -w "password" -s computername -d -p "printer name"
This deletes a printer.
Adding a printer is more complex, as you have to install a driver,create a port, and then link them all together.
I used the MicrosoftDeploymentToolkit_x64 to create a repository.
Once installed launch DeploymentWorkbench
Here's a script for installing printers that I wrote based on the above scripts.
Line 222 has to be modified to point to your driver repo.
If you don't have a domain try either omitting that and the slash completely OR substituting a period for domain. Either administrator or .\administrator
cscript printer.vbs -u domain\username -w "password" -d "HP Universal Printing PS (v6.6.0)" -i hpcu215v.inf -h "\\server name\drivers\USB\hpbuio200l_188.8.131.52_274C803A4F23C650047D1DF926CE1115098F5BDCEA7352C797E500E194FD2227" -p printername -s computername