ConfigMgr Inventory: Per User Network Printer Mapped Information (datashift replacement)
Back when Windows 98 and Windows XP were the norm, there was a script available called "datashift", which would grab information from users regarding their printers, and included any network mapped printers. It worked because everyone was a local admin--that's no longer the case.
This is a replacement for that older utility. If you still have a need for the per-user information regarding network printer connections, here is a way to obtain that information.
The basics of how it works is this. There are two vbscripts that run. One runs as SYSTEM, and it's only purpose is to create a custom namespace in WMI (if it doesn't already exist), and grant permissions to all of your domain users to that custom namespace--so they can populate it with the results of script #2. Script #2 runs, only when a user is logged in, with user rights. That's because the script needs to read information about that specific logged-in users mapped printer information.
The results of the 2nd script end up in that custom WMI namespace, and will have the following information:
DateScriptRan = the exact date and time that the script ran to gather this user-specific information.
UserDomain = whomever is logged in, what their domain is.
UserName = whomever is logged in, what their username is.
deviceid -- The Mapped Printer
Drivername -- Driver offered from the Server
Location -- Metadata from the print share (if populated)
Comment -- Metadata from the print share (if populated)
ServerName -- ServerName where the print share originated
ShareName -- ShareName of that shared printer
End result: After deploying these two scripts, you will be able to answer the question from your server team of "who is actually mapping to these network printers". Of course, the main limitation is this is per-user information.
Ok, enough of how it works. You really want to know *exactly* what to do, right? Let's start! Your Source folder for the package will contain 3 things: WMINameSpaceAndSecurity.VBS WMISecurity.exe MappedPrinters.vbs
The .vbs files are at this link --> MappedPrinters <--. Note that WMISecurity.exe is not attached here; just search using your favorite search engine to find and download wmisecurity.exe. The one I used was version 184.108.40.206058 --maybe there are later versions of this .exe; but that's the one I found, and it worked.
You will need to make 1 change to "WMINameSpaceAndSecurity.vbs", this line: strDomain = "YOURDOMAINHERE" Modify that to be your domain (the domain your users are in that will be logging in and running script #2).
Create two programs; the first runs cscript.exe WMINameSpaceAndSecurity.vbs, whether or not a user is logged in, with Administrator rights. The second runs cscript.exe MappedPrinters.vbs, only when a user is logged in, with user rights. The 2nd one; you want to "run another program first", and have it run the first one. It only needs to run the 1st program once, per computer; it doesn't need to re-run.
Advertise the 2nd program to a collection (I recommend a test/pilot first), and confirm that it works as you expect. If you want to confirm the data is there, look in root\CustomCMClasses (not root\cimv2) for cm_MappedPrinters, that there are instances there for mapped printers for that user.
If you are satisfied it's there locally, either add the below to sms_def.mof (if you are ConfigMgr07) or import it into Default Client Agent Settings, Hardware Inventory (if you are CM12)
// NOTE! Requires pre-requisite scripts run on every client!
class cm_MappedPrinters : SMS_Class_Template
[SMS_Report(TRUE)] string Comment;
[SMS_Report(TRUE)] string DateScriptRan;
[SMS_Report(TRUE)] string DriverName;
[SMS_Report(TRUE)] string Location;
[SMS_Report(TRUE),key] string PrinterDeviceID;
[SMS_Report(TRUE)] string ServerName;
[SMS_Report(TRUE)] string ShareName;
[SMS_Report(TRUE)] string UserDomain;
[SMS_Report(TRUE)] string UserName;
Sit back, relax for a bit... then invoke a hardware inventory on your test boxes, and see if the data shows up in your database in v_gs_MappedPrinters0. If so, deploy the advert to your real target collection of users or computers, and wait for the data to show up. Depending upon your need for this information; you may or may not want to have the advert run on a recurring basis (weekly? monthly?) or just gather it for a week or so (just enough to answer the question) then delete the advert and change the Inventory from TRUE to FALSE (until the next time they ask).
Potential SQL report:
s1.Netbios_Name0 as [Computer Name],
prn.userdomain0 as [User Domain],
prn.username0 as [UserName],
prn.DateScriptRan0 as [Date Information Obtained],
prn.PrinterDeviceID0 as [Printer DeviceID],
prn.servername0 as [Server hosting the printer share],
prn.Sharename0 as [Share Name of the printer],
prn.Location0 as [If metadata exists on the print share, Location information],
prn.Comment0 as [If metadata exists on the print share, Comments],
prn.Drivername0 as [Driver offered by the printshare]
from v_R_System s1
join v_gs_mappedprinters0 prn on prn.resourceid=s1.ResourceID
order by s1.netbios_name0
- Created on .