{"id":102,"date":"2007-12-05T11:50:00","date_gmt":"2007-12-05T18:50:00","guid":{"rendered":"http:\/\/www.jasemccarty.com\/blog\/2007\/12\/printer-migration-script.html"},"modified":"2007-12-05T11:50:00","modified_gmt":"2007-12-05T18:50:00","slug":"printer-migration-script","status":"publish","type":"post","link":"https:\/\/www.jasemccarty.com\/blog\/printer-migration-script\/","title":{"rendered":"Printer Migration Script"},"content":{"rendered":"<p>Not sure if you&#8217;ve every had an issue where you have to move printers from one print server to another&#8230; I have had this come up a couple times&#8230;<\/p>\n<p>Here&#8217;s a little vbs that can be executed from a logon script, that will look at a mapped printer&#8217;s connection (which server it is on), remove it, and then map it to another system.<\/p>\n<p>Keep in mind, all the printers on NEWSERVER must have the same share names as the OLDSERVER.<\/p>\n<p>Basically this script enumerates each printer, looks for the server it is mapped from, deletes the printer, and then adds the new printer, which happens to be the same printer, but mapped on a different server.<\/p>\n<p>Here is the code:<\/p>\n<blockquote><p>On Error Resume Next<br \/>\nDim strComputer<br \/>\nDim objWMIService<br \/>\nDim colItems<br \/>\nDim WshNetwork<\/p>\n<p>Set WshNetwork = WScript.CreateObject(&#8220;WScript.Network&#8221;)<\/p>\n<p>strComputer = &#8220;.&#8221;<br \/>\nSet objWMIService = GetObject(&#8220;winmgmts:\\&#8221; &amp; strComputer &amp; &#8220;rootcimv2&#8221;)<br \/>\nSet colItems = objWMIService.ExecQuery(&#8220;Select * from Win32_Printer&#8221;,,48)<br \/>\nFor Each objItem in colItems<br \/>\nIf objItem.ServerName = &#8220;\\OLDSERVER&#8221; then<br \/>\nWshNetwork.RemovePrinterConnection objItem.ServerName &amp; &#8220;&#8221; &amp; objItem.ShareName, true, true<br \/>\nWshNetwork.AddWindowsPrinterConnection &#8220;\\NEWSERVER&#8221; &amp; objItem.Sharename<br \/>\nEnd If<br \/>\nNext<\/p><\/blockquote>\n<p>If you want to download it, you can find it <a href=\"\/scripts\/moveprinters.txt\"><span style=\"font-weight: bold;\">here<\/span><\/a>.<\/p>\n<p>As always, you are welcome to use the script, but I will not be held liable if any issues arise.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Not sure if you&#8217;ve every had an issue where you have to move printers from one print server to another&#8230; I have had this come &hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-102","post","type-post","status-publish","format-standard","hentry","category-vbs"],"_links":{"self":[{"href":"https:\/\/www.jasemccarty.com\/blog\/wp-json\/wp\/v2\/posts\/102","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jasemccarty.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jasemccarty.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jasemccarty.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jasemccarty.com\/blog\/wp-json\/wp\/v2\/comments?post=102"}],"version-history":[{"count":0,"href":"https:\/\/www.jasemccarty.com\/blog\/wp-json\/wp\/v2\/posts\/102\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.jasemccarty.com\/blog\/wp-json\/wp\/v2\/media?parent=102"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jasemccarty.com\/blog\/wp-json\/wp\/v2\/categories?post=102"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jasemccarty.com\/blog\/wp-json\/wp\/v2\/tags?post=102"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}