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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.