Skip to content
Menu
The Lonely Administrator
  • PowerShell Tips & Tricks
  • Books & Training
  • Essential PowerShell Learning Resources
  • Privacy Policy
  • About Me
The Lonely Administrator

Export Registry Printer Information I came…

Posted on November 2, 2011July 2, 2013

Export Registry Printer Information

Manage and Report Active Directory, Exchange and Microsoft 365 with
ManageEngine ADManager Plus - Download Free Trial

Exclusive offer on ADManager Plus for US and UK regions. Claim now!

I came across this post http://www.oncallpros.com/2011/11/02/powershell-export-your-print-configuration-from-registry/ on exporting printer information from the registry in PowerShell. I wanted to offer some constructive suggestions but could find no way to comment so I'll do so here.

First, the article introduces some good PowerShell concepts. I like that he is using Test-Path. Although I'd suggest using Join-Path instead of concatenation. I also like the use of Write-Host to display progress. An even better approach for a future version might be to use Write-Progress. I'm going to see about using that more myself as I think it is a cmdlet that doesn't get the attention it deserves.

But my main concern with the script is that it feels too much like VBScript and parsing text. He's not really taking advantage of the PowerShell pipeline. The core command can be this one line command.

get-childitem HKLM:SYSTEMCurrentControlSetControlPrint -Recurse |
get-itemproperty |
select @{Name="RegKey";Expression={Convert-Path$_.pspath}},* -exclude PSParentPath,PSChildname,PSProvider,PSPath

I wasn't looking for a one line command, it just turned out that way.

Personally, this is the code that I would put in the script because it writes objects to the pipeline. Now I have options. If I want a formatted text list I can do it:

PS C:> c:sciriptsget-printerregistry.ps1 | format-list | out-file printers.txt

Or perhaps today I need it as an xml file I wan reimport later.

PS C:> c:sciriptsget-printerregistry.ps1 | export-clixml printers.xml

The point is to offer flexibility and think objects in the pipeline.

On a more personal (pet peeve) note, if you are going to post code samples more than a few lines long, please, please offer a text file download. Copying and pasting code from websites is ugly and time consuming.

So, look at the original post and look at my suggestions. What do you think?

Powershell – Export your print configuration from registry | On-Call Pros, LLC

I was asked to produce this script for follow up checking of driver versions later on or possible settings which can cause problems.   The idea would be that a master file is updated on a website and ...


Behind the PowerShell Pipeline

Share this:

  • Click to share on X (Opens in new window) X
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on Mastodon (Opens in new window) Mastodon
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Pocket (Opens in new window) Pocket
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to print (Opens in new window) Print
  • Click to email a link to a friend (Opens in new window) Email

Like this:

Like Loading...

Related

reports

Powered by Buttondown.

Join me on Mastodon

The PowerShell Practice Primer
Learn PowerShell in a Month of Lunches Fourth edition


Get More PowerShell Books

Other Online Content

github



PluralSightAuthor

Active Directory ADSI Automation Backup Books CIM CLI conferences console Friday Fun FridayFun Function functions Get-WMIObject GitHub hashtable HTML Hyper-V Iron Scripter ISE Measure-Object module modules MrRoboto new-object objects Out-Gridview Pipeline PowerShell PowerShell ISE Profile prompt Registry Regular Expressions remoting SAPIEN ScriptBlock Scripting Techmentor Training VBScript WMI WPF Write-Host xml

©2025 The Lonely Administrator | Powered by SuperbThemes!
%d