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-2.0.3.1.exe sha1:ee47505ebfb2790b9da8a20ed70e67158e9753d0 size:342528 http://software.bigfix.com/download/bes/util/RunAsCurrentUser-2.0.3.1.exe

// DISABLE 'DO YOU WISH TO TRUST THIS PRINTER' DIALOG WINDOW

delete __createfile

createfile until –EOF-
REGEDIT4
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Printers\PointAndPrint]
“Restricted”=dword:00000001
"TrustedServers"=dword:00000000
"ServerList"=""
“InForest”=dword:00000000
"NoWarningNoElevationOnInstall"=dword:00000001
"UpdatePromptSettings"=dword:00000002
-EOF-
delete DisablePromptWindow.reg
copy __createfile DisablePromptWindow.reg
wait regedit /S DisablePromptWindow.reg
delete __createfile

// CREATE NEW PRINT QUEUE

// 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 \0701.this.is.a.printer” & 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-2.0.3.1.exe” --w --q cmd.exe /C c:\users\public\AddPrinter1.bat
endif

So…If I have a printer named BL480-FL2-RM220-X6360 on server \theprntsvr.this.is.a.printer, 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 \ \0701.this.is.a.printer\ 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…