Friday, October 3, 2014

Computer Make & Model Report

First Report I'd like to share is my Computers Make & Model report. It's a simple report that lists all computers in a collection with it's make and model plus some other information. The two main features of this report is that it displays the correct model name for Levovo's and the little colored square that visualizes changes from green ,to yellow to red based on hos long the computer have been offline.


For Lenovos you get the Model ,default they show up as for instance "23444TG" instead of "Thinkpad T430"... 



To get this report up and running in your environment you just need to download the .RDL file and import it into your environment. Then you need to edit it in Report Builder and change the "Datasource1" to point to your Configmgr SQL.










The report should now work(sort of) ,there are still some stuff you might want to change:

  • The Bar Chart have a filter to only show models that there's 3 or more of.(Category Group Filter)
  • The list of avaible collections is controlled by the parameter collectionID witch in turn gets its values from the "Dataset2" query. Change the "Dataset2" query to something like:
SELECT Name, CollectionIDFROM v_Collection where Name Like '%yourKeyword%'Order by Name asc

  • The Dataset contains some more information that you can add to the tablix if you want ,for instance "Chassis Type" 
  • The values for the colured square are controlled by the two parameters colourfadeyellow and colourfadered that ,you guessed it...controlles how many days the computers need to be offline before the colour starts fading to yellow and red.






If you are interested in just the query ,here it is:

SELECT DISTINCT dbo.v_r_system.resourceid, 
                dbo.v_r_system.name0 
                AS ComputerName, 
                dbo.v_r_system.resource_domain_or_workgr0 
                AS Domain, 
                dbo.v_r_system.user_name0 
                AS LastloggedonUser, 
                Max(dbo.v_ra_system_systemouname.system_ou_name0) 
                AS OU, 
                dbo.v_gs_computer_system.manufacturer0 
                AS Manufacturer, 
                CASE 
                  WHEN dbo.v_gs_computer_system.manufacturer0 LIKE 'Lenovo' THEN 
                  v_gs_computer_system_product.version0 
                  ELSE dbo.v_gs_computer_system.model0 
                END 
                AS Model, 
                dbo.v_gs_pc_bios.serialnumber0 
                AS Serialnumber, 
                CASE 
                  WHEN dbo.v_gs_computer_system.manufacturer0 LIKE 'Lenovo' THEN 
                  v_gs_computer_system.model0 
                  ELSE dbo.v_gs_computer_system_product.version0 
                END 
                AS Details, 
                dbo.v_gs_operating_system.caption0 
                AS OS, 
                dbo.v_gs_operating_system.csdversion0 
                AS ServicePack, 
                Replace(dbo.v_gs_processor.name0, 'Intel(R) Core(TM)', 
                'Intel Core') AS CPU, 
                dbo.v_gs_processor.maxclockspeed0 
                AS CPUinGhz, 
                Round(Round(CONVERT(FLOAT, 
                            dbo.v_gs_x86_pc_memory.totalphysicalmemory0) / 
                            1048576, 2) 
                      * 1024, 0) 
                AS MemoryInMB, 
                Round(CONVERT(FLOAT, dbo.v_gs_logical_disk.size0) / 1024, 2) 
                AS DisksizeinGB, 
                CASE 
                  WHEN v_gs_system_enclosure.chassistypes0 LIKE '1' THEN 
                  'Virtual' 
                  WHEN v_gs_system_enclosure.chassistypes0 LIKE '2' THEN 
                  'Blade Server' 
                  WHEN v_gs_system_enclosure.chassistypes0 LIKE '3' THEN 
                  'Desktop' 
                  WHEN v_gs_system_enclosure.chassistypes0 LIKE '4' THEN 
                  'Low-Profile Desktop' 
                  WHEN v_gs_system_enclosure.chassistypes0 LIKE '5' THEN 
                  'Pizza-Box' 
                  WHEN v_gs_system_enclosure.chassistypes0 LIKE '6' THEN 
                  'Mini Tower' 
                  WHEN v_gs_system_enclosure.chassistypes0 LIKE '7' THEN 'Tower' 
                  WHEN v_gs_system_enclosure.chassistypes0 LIKE '8' THEN 
                  'Portable' 
                  WHEN v_gs_system_enclosure.chassistypes0 LIKE '9' THEN 
                  'Laptop' 
                  WHEN v_gs_system_enclosure.chassistypes0 LIKE '10' THEN 
                  'Notebook' 
                  WHEN v_gs_system_enclosure.chassistypes0 LIKE '11' THEN 
                  'Hand-Held' 
                  WHEN v_gs_system_enclosure.chassistypes0 LIKE '12' THEN 
                  'Mobile Device in Docking Station' 
                  WHEN v_gs_system_enclosure.chassistypes0 LIKE '13' THEN 
                  'All-in-One' 
                  WHEN v_gs_system_enclosure.chassistypes0 LIKE '14' THEN 
                  'Sub-Notebook' 
                  WHEN v_gs_system_enclosure.chassistypes0 LIKE '15' THEN 
                  'Space Saving Chassis' 
                  WHEN v_gs_system_enclosure.chassistypes0 LIKE '16' THEN 
                  'Ultra Small Form Factor' 
                  WHEN v_gs_system_enclosure.chassistypes0 LIKE '17' THEN 
                  'Server Tower Chassis' 
                  WHEN v_gs_system_enclosure.chassistypes0 LIKE '18' THEN 
                  'Mobile Device in Docking Station' 
                  WHEN v_gs_system_enclosure.chassistypes0 LIKE '19' THEN 
                  'Sub-Chassis' 
                  WHEN v_gs_system_enclosure.chassistypes0 LIKE '20' THEN 
                  'Bus-Expansion chassis' 
                  WHEN v_gs_system_enclosure.chassistypes0 LIKE '21' THEN 
                  'Peripheral Chassis' 
                  WHEN v_gs_system_enclosure.chassistypes0 LIKE '22' THEN 
                  'Storage Chassis' 
                  WHEN v_gs_system_enclosure.chassistypes0 LIKE '23' THEN 
                  'Rack-Mounted Chassis' 
                  WHEN v_gs_system_enclosure.chassistypes0 LIKE '24' THEN 
                  'Sealed-Case PC' 
                  ELSE 'Unknown' 
                END 
                AS [Chassis Type], 
                health.lastactivetime 
                AS Active 
FROM   dbo.v_r_system 
       LEFT OUTER JOIN dbo.v_gs_computer_system 
                    ON dbo.v_r_system.resourceid = 
                       dbo.v_gs_computer_system.resourceid 
       LEFT OUTER JOIN dbo.v_ra_system_systemouname 
                    ON dbo.v_r_system.resourceid = 
                       dbo.v_ra_system_systemouname.resourceid 
       LEFT OUTER JOIN dbo.v_gs_pc_bios 
                    ON dbo.v_r_system.resourceid = dbo.v_gs_pc_bios.resourceid 
       LEFT OUTER JOIN dbo.v_gs_operating_system 
                    ON dbo.v_r_system.resourceid = 
                       dbo.v_gs_operating_system.resourceid 
       LEFT OUTER JOIN dbo.v_gs_x86_pc_memory 
                    ON dbo.v_r_system.resourceid = 
                       dbo.v_gs_x86_pc_memory.resourceid 
       LEFT OUTER JOIN dbo.v_gs_processor 
                    ON dbo.v_r_system.resourceid = dbo.v_gs_processor.resourceid 
       LEFT OUTER JOIN dbo.v_gs_logical_disk 
                    ON dbo.v_r_system.resourceid = 
                       dbo.v_gs_logical_disk.resourceid 
                       AND dbo.v_gs_logical_disk.deviceid0 = Substring( 
       dbo.v_gs_operating_system.windowsdirectory0, 1, 2) 
       LEFT OUTER JOIN dbo.v_gs_system_enclosure 
                    ON dbo.v_r_system.resourceid = 
                       dbo.v_gs_system_enclosure.resourceid 
       LEFT OUTER JOIN dbo.v_gs_computer_system_product 
                    ON dbo.v_r_system.resourceid = 
                       dbo.v_gs_computer_system_product.resourceid 
       RIGHT OUTER JOIN v_ch_clientsummary health 
                     ON health.resourceid = dbo.v_r_system.resourceid 
WHERE  ( dbo.v_gs_pc_bios.serialnumber0 IS NOT NULL ) 
       AND ( dbo.v_r_system.client0 = 1 ) 
AND dbo.v_r_system.resourceid IN (SELECT resourceid  
                                  FROM   dbo.v_fullcollectionmembership  
                                  WHERE  
    dbo.v_fullcollectionmembership.collectionid  
    = @CollectionID)  
GROUP  BY dbo.v_r_system.resourceid, 
          dbo.v_r_system.name0, 
          dbo.v_r_system.resource_domain_or_workgr0, 
          dbo.v_r_system.user_name0, 
          dbo.v_gs_computer_system.manufacturer0, 
          dbo.v_gs_computer_system.model0, 
          dbo.v_gs_pc_bios.serialnumber0, 
          dbo.v_gs_computer_system_product.version0, 
          dbo.v_gs_operating_system.caption0, 
          dbo.v_gs_operating_system.csdversion0, 
          dbo.v_gs_processor.name0, 
          dbo.v_gs_processor.maxclockspeed0, 
          dbo.v_gs_x86_pc_memory.totalphysicalmemory0, 
          dbo.v_gs_logical_disk.size0, 
          dbo.v_r_system.creation_date0, 
          dbo.v_gs_system_enclosure.chassistypes0, 
          health.lastactivetime 

25 comments:

  1. Very nice! Thank you for sharing.

    One strange thing seems to have happened to our Lenovo clients - they don't show up in the report? The clients are there, but he model column is blank.

    Dell, Compaq, HPs etc is showing fine, only Lenovo seems to be affected.

    I guess this has something to do with Lenovo storing their model number in another WMI class, but I thought this was fixed in SCCM 2012. I'm running 2012 R2 CU3, btw.

    Have you done something to you DB or Lenovo clients to make sure their model number appear in the report?

    ReplyDelete
    Replies
    1. Ah - It seems WIN32_ComputerSystemProduct isn't collected by default - I have enabled it and hope this will fix the missing data...

      Delete
    2. Yep, that was it. Move along, nothing to see here... ;)

      Oh well, if anyone else if having the same issue, make sure your default client policy is collecting Hardware Inventory for Win32_ComputerSystemProduct

      Delete
  2. mate your blog is gold. thanks for the reports :)

    ReplyDelete
  3. can we include lasst user logged in and email ID in the query ? if yes...can i know how ?

    ReplyDelete
    Replies
    1. Yes ,Last User Logged User is already in the report (Second Column). if you need more details on the users ,you can join in the v_R_User view and add fields like e-mail ,users displayname and so on...
      Add a join rule to the query:

      "left outer join v_r_user on v_r_system.User_Name0 = v_r_user.User_Name0"

      E-mail address is stored in the column called mail0

      Delete
    2. Great report! Is there anyway to remove the embedded photo or to change it?

      Also, any idea why it hangs when i try and run the report in IE? Running it from the SCCM console works fine but trying to run it from the webpage just hangs

      Delete
    3. To remove/change the embedded photo
      Open "http://servername/reports" hover over the report, click on the arrow that appears and select "Edit in Report Builder"

      To Delete it ,just rightclick the logo and select delete

      To modify ,right click images in the left hand menu and select add image. Then rightclick the logo ,select image properties and change "use this image"

      Delete
    4. Hi Thomas,

      I'm also trying to add e-mail adress to the report. Can you explain in more detail how I do this? Would be much appreciated.

      Br,
      Rasmus

      Delete
  4. Please add MAC Address and IP Address, I don't know how to add in your RDL file,
    Thanks for all

    ReplyDelete
  5. Hi,
    Great report.
    Please could you help me, I noticed that if there is only 2 or less pc's of a certain model, it doesn't add that to the graph. How do I do about getting it to add ALL pc's to the graph?
    Thank you in advance

    ReplyDelete
    Replies
    1. Hi

      Yes i've filtered out all models that there are 3 or less of to minimize clutter.
      If you want to remove the filter:

      1) Select the chart.
      2) Under Category Groups ,Right Click Model and select "Group Properties"
      3) Under Filters you'll find the filter condition. you can edit or remove it.

      I will release a new and improved version of this report "soon":-)
      Got a few ideas and improvements i want to implement.


      Delete
    2. Hello, I am experiencing same thing. If I go in Report Builder to the Category Groups > Model > Filters I see there is a filter on integer of 3. Either way, if I delete the filter entirely or change the value to something like 10 and save the report, if I go back into the Filter properties again it reverts it back to 3. Am I missing something? Great report BTW!

      Delete
  6. Hi,

    Could you suggest me how can i get desktop monitor report in SCCM R2 with the Make, model, serial number.

    Thanks in advance

    ReplyDelete
    Replies
    1. Screen info is stored in the [v_GS_DESKTOP_MONITOR] view.
      Doesn't seem to be any good ,only shows one monitor for machines with multiple monitors.
      (Problem is that the WMI_Deskopmonitor32 class seems to be hit and miss)

      Delete
  7. Takker for awesome ConfigMgr rapporter. Denne har jeg brukt mye men har støtt på et lite problem nå. Nyere Dell laptoper 7450/7250 og 7510 kommer inn med duplikater. For eks 7510 som vi har 36 stk av kommer som 68 stk i rapporten. Eldre dell pcer kommer med rett antall, det samme gjelder lenovo. Har du noe ide på hva dette kan skyldes ?

    ReplyDelete
  8. Er et par ting i queryen som kan forårsake doble rader, men snodig at det bare er noen modeller som dukker opp dobbelt.
    Jeg ville kjørt querien fra rapporten og slengt på en "AND v_r_system.name0 = 'Maskinnavn' for å se hva som er forskjellig."

    Vil komme med en ny versjon av denne rapporten "Snart" ,med en ganske mye bedre query:-)
    (queryen fra denne var noe jeg egentlig skrev for å mate vårt helpdesksystem med data)

    ReplyDelete
  9. Chassis type :-) Laptop og Mobile Device in Docking Station

    ReplyDelete
  10. Hi Thomas, great report again! We have 32 and 64 bits machines. Could it be doable to integrate a column with that information?
    Thanks again :-)

    ReplyDelete
    Replies
    1. Hi ,should be easy the view that stores this info is already joined in the query. You just need to add the field to the query.
      In report builder ,mpodify the Dataset1 query to include the "v_gs_computer_system.SystemType0" field, add it to both the "select part" (between "select" and "from") and the "group by part" (bottom) of the query.
      Then you should see the SystemType0 datafield in the list in report builder, just drag it to the table and you should be good to go.

      Delete
  11. Hi Thomas,

    Thanks a lot for sharing this report, It's very helpful. But for some odd reason only laptop model shows in the report duplicated. It's Dell Latitude 7275.

    Each Laptop shows twice in two different row which gives wrong number in the chart. any idea how I can fix this?

    https://i.imgur.com/ypFl2Qd.png

    ReplyDelete
    Replies
    1. Did you ever figure this out? This is a great report, but getting duplicates as well.

      Delete
  12. We have a lot of model so the columns are appearing very small. Is is possible to enlarge the columns?

    ReplyDelete
  13. Hi, this is awesome. Im wondering how easy it is just to return Dell machines. We do have LENOVO old estate in SCCM and its returning this data for the few machines knocking about but our main estate is Dell and we have a service agreement with Dell so we only need to inventory these, not Lenovo.

    Secondly I am wondering if a column could be added that counts if serialnumber = to asset tag? Thankyou

    ReplyDelete
  14. Thanks thia is just what we needed!

    ReplyDelete