PowerShell Script Help for Getting Printer Information From Registry

We have users who have a local Epson printer. The issue we are having is dumping the subkeys HKEY_CURRENT_USER\Printers\DevModePerUser into an array and extracting the Epson key.

Step 1

Identify if there is a printer SubKey that starts with Epson under [HKEY_CURRENT_USER\Printers\DevModePerUser]

Step 2

If it exists copy the key name and write it to the key data below and enable TillParallelReceipt

[HKEY_CURRENT_USER\Software\TCDL\Login]
"TillParallelReceipt"=dword:00000000
"TillParallelPrinter"="cmbTillParallelPrinter"

Example:
"TillParallelReceipt"=1
"TillParallelPrinter"="Epson TMV118V-Reception"

Any help would be greatly appreciated, so far everything tried has failed.
robertarensonAsked:
Who is Participating?
 
oBdACommented:
I hope I understood you correctly:
$RegKeySource = "HKCU:\Printers\DevModePerUser"
$RegKeyTarget = "HKCU:\Software\TCDL\Login"
$PrinterLike = "Epson*"
$PrinterName = Get-Item -Path $RegKeySource |  Select-Object -ExpandProperty Property | ? {$_ -like $PrinterLike}
If ($PrinterName) {
	Set-ItemProperty -Path $RegKeyTarget -Name "TillParallelReceipt" -Type DWord -Value 1
	Set-ItemProperty -Path $RegKeyTarget -Name "TillParallelPrinter" -Type String -Value $PrinterName
} Else {
	Throw "No printer matching '$($PrinterLike)' found!"
}

Open in new window

0
 
robertarensonAuthor Commented:
Thank you so very much oBdA for the help, I am testing it out now to see if it works. I will let you know as soon as I can.

Thank you again for your help.
0
 
robertarensonAuthor Commented:
Thank you so very much oBdA, worked like a charm. Really appreciate your assistance.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.