How to Collect Default Printer

Recently a user had a requirement to collect the default printer assigned to every Windows PC. He posted his request on the http://communities.bmc.com as he could not find the solution easily himself. Even though Asset Core does collect printer details under each device, (Asset Name > Inventory > Hardware > Printer), it does not collect the DEFAULT printer as this is USER specific and Asset Core collects data under SYSTEM. I have often said the FPAC can do just about anything you will ever need so I got a chance to prove it.
There are a number of ways to solve for this request and I will show you two of these methods.

Option number 1. (Read Registry)

  • Create Operational Rule (Name it Default Printer)
  • Add 2 Steps
    • Collect Registry Key Value
      • HKEY_CURRENT_USERSoftwareMicrosoftWindows NTCurrentVersionWindows
      • Value=Device
    • Update Custom Inventory
  • Run it on a couple of TEST devices to ensure you get the results you are expecting.
    • NOTE: Because the KEY being read is only available when a user is actually logged on this Operational Rule will only return results when there is an active session. This should be assigned “At Session Start”

Here are some screen shots:

Collect Registry Value

Collect Registry Value


Results of Operational Rule:
Custom Inventory Results

Custom Inventory Results


The result will return the Printer Name, Driver and Port Name.
Be aware that due to environmental issues such as the configuration of your END POINT CLIENT, GPO, REGEDT32 setting or any other security limitations you may not get any results back. If that is the case then consider Option 2 (Requires Software Deploy Module).
Option number 2. (Deploy Package to run WMI)

  • Create Package
    • BAT file
      • Line of code:
        • START “” /W CMD /C WMIC /Output:C:TempDefaultPrint.txt Printer Where “Default=TRUE” Get DeviceID,PortName
    • Run the BAT file
      • Notice that I am using the C:TEMP folder to OUTPUT my result file. You may change the location or use Operational Rule step to create the C:TEMP directory.
      • A new txt file is created with the results of the BAT file
    • Add step to read the txt file (File Analysis via Regular Expression)
      • The REGEX to use: (.*$)
    • Update the Custom Inventory (Step)

This too must be run “At Session Start Up” to ensure that the “User’s” default Printer is selected – A User must be logged in. In addition “Run as Current User” must also be selected so the SYSTEM account does not execute the script since no printer is assigned to SYSTEM.
I broke the operations into 2 separate Operational Rules.

  1. Package Deploy
  2. Execute the BAT file (I left the BAT file in place so I can run at every Session Start so if the default printer ever changes then the DELTA will then get updated. Even though I run this BAT file at the beginning of each login it will only send back data if changed.

Here are my screen shots:
Operational Rule to get the BAT file to local machine:
Get BAT file to Device (Package)
Operational Rule to execute at every Session Start:
Update Info at each Session Start
How to set for Current User:

Scheduler

Scheduler


Result of Regular Expression:
REGEX Result
Operational Rule to collect REGEX file data
File Analysis via Regular Expression

File Analysis via Regular Expression


I found this method to always return results but as you can see it is more involved than option 1.
If your organization requires an inventory of local Printers that users are “currently” using this these methods will return the results you require.

2013-07-26T14:31:44+00:00July 26th, 2013|FPAC|