Printer Migration to new servers

So I am running through a print server migration on a 10000+ client network and want to use IEM to do the following –

  • Look in HKEY_USER for currently mapped printers
  • Line up old print server names with new one in order to create an append file to execute the printer mapping
  • Once mapping is complete, ensure the old mapped printer is removed…ONLY if the new printer was mapped successfully.

I have successfully completed the first two tasks with the following :

if {exists current user}
prefetch RunAsCurrentUser- sha1:ee47505ebfb2790b9da8a20ed70e67158e9753d0 size:342528


delete __createfile

createfile until –EOF-
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Printers\PointAndPrint]
delete DisablePromptWindow.reg
copy __createfile DisablePromptWindow.reg
wait regedit /S DisablePromptWindow.reg
delete __createfile


// theprntsvr01v

if {exists key whose (name of it contains regex “( theprntsvr01).*”) of keys “Printers\Connections” of keys whose (name of it contains regex “(S-1-5-21)-\d{10}}-\d{10}}-\d{7}}-\d{6}}$”) of keys “HKEY_USERS” of registry}

appendfile {concatenation “%0d%0a” of (“Start \” & it) of (following texts of firsts “01v,” of it of names of it) of keys whose (name of it contains regex “(theprntsvr).*”) of keys “Printers\Connections” of keys whose (name of it contains regex “(S-1-5-21)-\d{10}}-\d{10}}-\d{7}}-\d{6}}$”) of keys “HKEY_USERS” of registry}

delete c:\users\public\AddPrinter1.bat
copy __appendfile c:\users\public\AddPrinter1.bat
delete __appendfile

waithidden “__Download\RunAsCurrentUser-” --w --q cmd.exe /C c:\users\public\AddPrinter1.bat

So…If I have a printer named BL480-FL2-RM220-X6360 on server \, the above relevance will create a bat file to remap to the new server for multiple printers. In this case, the response to this action will be the following command in a .bat file -

Start \ \\ BL480-FL2-RM220-X6360

The printer name would have been pulled from the registry entry under HKEY_USERS

The issue I am having is coming up with a method to look at the printers that have been mapped and delete the appropriate printer entry it mapped from without deleting any other printers in the process.

Hope this makes sense…

Still banging my head on this…on a few possibilities and thinking this should be easy. I must be missing something…