Hello fellow Ninjas!
DISCLAIMER: I did not create this entire solution myself. I used bits and pieces from around the net and with a high level of determination and significant testing I have found a viable solution. The reason for this blog is I couldn't find a complete step-by-step solution.
The K1000 currently only inventories in Device Inventory local (non network) printers. The reason why the K1000 doesn't inventory network printers are because of the following reason.
Reason: Network printers are installed, traditionally, per user. Meaning if someone else logged on they wouldn't see said network printer. The K1000 Agent, which is responsible for inventory (plus much more) executes as: SYSTEM, not the logged-in-user.
Due to this fact to be able to inventory network printers we'll have to leverage KACE's other assets in order to accomplish our goal. Fear not ninjas, if there is a will there is a way!
Step 1: Create an Online KScript with the following settings
Not sure if you can see everything, but here is the important information.
Windows Run As MUST be set to Logged-in User.
The only step should be to run a batch script with the following code:
Cscript %WINDIR%\System32\Printing_Admin_Scripts\en-US\Prnmngr.vbs -l > C:\ProgramData\Dell\KACE\user\FPL.txt
findstr /v "Script Copyright Default Server Location Comment Parameters Attributes Priority Average status Extended error Share processor type" C:\ProgramData\Dell\KACE\user\FPL.txt > C:\ProgramData\Dell\KACE\user\PrintersList.txt
ECHO Last Sync:>>"C:\ProgramData\Dell\KACE\user\PrintersList.txt"
ECHO %date% >>"C:\ProgramData\Dell\KACE\user\PrintersList.txt"
The high level approach is this:
First delete the file PrintersList.txt at a given location
Then execute a built-in (into Windows) VBS script that outputs all your logged-in users printers (local + network) to a txt file named: FPL.txt to a given location
Then parse the FPL.txt file and capture the useful information (Printer, Drive, and Port Name) and then write that to another txt file named: PrintersList.txt to a given location
Then delete the FPL.txt file (since we got what we needed from it)
Then append a newline to the PrintersList.txt file
Then append: Last Sync: to the PrintersList.txt file
Then append a timestamp to the PrintersList. txt file
What the end result is something that looks like this:
I wanted to include a timestamp in the .txt file so that when this gets inventoried in our CIR rule (discussed below) we know the last time this was executed.
Now that we have a script that creates a .txt file with all of our printers we need to create a Custom Inventory Rule to read that file and included it in Device Inventory.
Now head over to Inventory -> Software in your K1000 and create a new entry with the following information:
The Custom Inventory Rule code should be:
ShellCommandTextReturn(cmd /c type C:\ProgramData\Dell\KACE\user\printerslist.txt)
So now that we have everything setup here are some things I wanted to discuss with you. I suggest scheduling the script to run either weekly or monthly as users' printers usually don't change and we don't need to bog down the K1000 running it at a shorter interval. Now there is one caveat to all of this. Caveat is that this only captures the list of available printers for the current logged-in user when the script is executed. If only a single user logs onto computer then this wont be an issue. However, if you have multiple users sharing a computer who have different printers then you will need to alter my solution to have the script execute against all users who have logged onto the computer (not sure how nor if it would be possible).
I wish all you ninjas luck out there and let me know if you have any questions!