configuration manager inventory powershell

In order to find information from our environment,very often we go out query the information directly at the source, on the network. We will query 100 hundreds of computers to gather information on a specific subject, and use it with conditional logic  to accomplish our daily tasks. If you Configuration Manager deployed in your infrastructure, and need to retrieve some information on your devices, before writing a script that would query all of your devices through WMI remotely, ask your self if you do not have that information already present in your ConfigMgr DataBase.

Everything that is returned through the Hardware and Software inventory is actually present in the Configuration Manager Database, and is out there waiting for you!

How to get information from the configuration manager inventory using PowerShell?

In My case, one of my tasks was to identify the all current Local Admins of all of the computers currently deployed. This task can be done in several ways, such as per script, querying WMI for example. But I had been decided that we would use the ConfigMgr Hardware inventory information that is pulled during the different hardware inventory cycles. For that, we first needed to extend the hardware inventory (Which can be done in seconds!).

This article is more on how to find your way through this more then a step by step, but if you want to follow along, you will need to extend your Hardware inventory by following this post on technet –> http://blogs.technet.com/b/sudheesn/archive/2014/12/12/collect-hardware-inventory-of-local-admins.aspx

 

Now the difficult part, is not actually not really how to extend the Hardware inventory, but more where do we actually get that information exactly from once it has been reported back?

If you are interested in seeing a step by step on how to extend your hardware inventory, I recommend you take a look at the following post that was part of ConfigMgr inventory series that I wrote –> How to extend Configuration Manager Hardware inventory Step by Step

As usual, WMI is my preferred the solution. But the main question I had, is where exactly in WMI? This WMI class that I just added cannot be documented on Technet. Where do I go to query the information that it contains? And what is that WMI queries name?

Look in the Configuration Manager inventory / Database after extending the hardware inventory:

Once we have extended the hardware inventory, we go ahead, and take a peek in the Configuration Manager database. If you are not in a hurry, wait until the next day. Like you are sure you have some data in it.

If you open SQL management studio, and naviagate to the following path:Databases\CM_<SiteName>\Views

you can scroll aaaaaall the way down to find dbo_.v_GS_LocalAdmins

That view will contain all the information that has been inventoried by your Configuration Manager Agents.

Configuration Manager Hardware inventory extension Database view

Configuration Manager Hardware inventory extension Database view

Now now knowing that the Database view name is V_GS_LocalAdmins I searched for something similar in the WMI repository. And after a moment, I got it!

PowerShell cconfiguration manager ustom WMI class location

Custom WMI class location

The WMI Class that has been created on the Configuration Manager Site server is named: SMS_G_System_LocalAdmins  and can be found in the Root\SMS\Site_<SiteName> Namespace.

Now that we have that information, it becomes a piece of cake to get the Local administrator group members from the configuration manager inventory with powershell.

Querying WMI to read data from configuration manager inventory database:

I finally ended up with the following function will help you get the list of all of the local admins per machine:

 

Remember, by extending the hardware inventory, we actually avoid our self’s to write a script that would go through all of the computers, connect to it, retrieve information, and store it somewhere in a DB. This is something we delegated to Configuration Manager, and he does it well.

 

Digg more into it:

http://trevorsullivan.net/2011/07/05/extreme-powershell-configmgr-extending-hardware-inventory/

 

 

By | 2016-10-19T21:00:13+00:00 June 29th, 2015|ConfigMgr, ConfigMgr 2007, ConfigMgr 2012, WMI|0 Comments

About the Author:

Stéphane is a dynamic and passionate Cloud and datacenter Microsoft MVP since. He is the founder of the Basel PowerShell user Group (BPUG), the co-founder of the French Speaking PowerShell UserGroup (FRPSUG), author, blogger, and received the community award "PowerShell Hero" from PowerShell.org. Stéphane has implemented microsoft infrastructure solutions in various countries of Europe and is currently working in Basel / Switzerland. Stéphane help his clients to reduce their global infrastructure costs by implementing Microsft infrastructure solutions by combining great products such as System Center, Windows Server, with heavy automation using Windows PowerShell. Stéphane loves languages, Belgium beer, French cheese and French Wine. If any of these topics are of your interest, don't hesitate to come and say hi.

Leave a Reply

%d bloggers like this: