List connected network printers in user session

This will list exact sharing name of printer. Complete network address of printer.
Useful to know before re-install user environment.

Files needed:

The code:
Explanation:
sed "s/.*\\Servers\\//g;" cut the output line content from line start till \Servers\
grep -v "^$" - remove empty lines
grep -v "HKEY_LOCAL_MACHINE" - remove lines which includes HKEY_LOCAL_MACHINE
sed "s/REG_SZ\|url//g" - deletes all REG_SZ and url
sed "s/^[ \t]*//g" - remove all white spaces and tabs at the start of line
sed "s/http://g;s/\//\\/g;" - deletes all http:; replace / with \

To list just the name use:
Related:
List locally installed printers on remote machine
Set group policy user logon or computer startup script to run locally

No comments: