Skip to main content

PowerShell + SCCM 2012 R2: Get the Client Info Easy Way

One of my friend Krishna called and asked me on how to get the report for the  Management Point to which SCCM clients (part of a Collection) report to.

This is normal day to day task in a ConfigMgr Admin's life and most of us would go and use Reports in Configuration Manager . But he wanted to do this using PowerShell...... hmmm :-?  Now you are talking :-b

If you are using Configuration Manager 2012 and haven't started using PowerShell then you as missing one of the Coolest things that can make your job easy.

In ConfigMgr 2007 we had an option to export the list of members from a Collection , see below:

This was convenient but sadly it's not there now.


But we can do a lot more if we choose to use PowerShell here.

This is not a very complex thing to do if you are comfortable with PowerShell, so I am going to do it 2 ways:

  1. Easy Way : using cmdlet Get-CMDevice
  2. WMI Way :P (next Post)

 Easy Way : using cmdlet Get-CMDevice

On your ConfigMgr Console top left corner Click and select "Connect via Windows PowerShell" (this is the last time am gonna put this in my post :) )


After you have your Console opened the ConfigurationManager PowerShell module will be loaded and you can now use the cmdlet Get-CMDevice. Note - When the console opens you will be placed in the drive named after your SiteCode something like DEX:\ in my case. If we want to run cmdlets shipped with ConfigMgr then that we need to do from inside this PSProvider.

Go ahead and open the help for the cmdlet and see that there are a lot of parameters and parameter sets but looking for the marked one here:




Well you can use this cmdlet in a lot many ways but as per my requirement I want to get the Devices in a specific collection and generate report. 

Let me take the "All Systems" as the collection here as I don't have many machines in my LAB. Below is a shot of my current members of it:



Now you can see I have already gone ahead and added the Management Point and Operating System property to the Column view (just have to right click on it and select these).

So below cmdlet will give you information about all the devices, the properties are overwhelming in number so going to save it in a variable here:

$Members = Get-CMDevice -CollectionName "All Systems"

To know what all properties the members of the Collection have, we can use :

$Members | Get-Member -MemberType Property

If you scroll down enough you will see there is a property named lastmpservername and deviceos , so go ahead and do this


$Members | select name,lastmpservername,deviceos

But strangely enough nothing gets returned back, Why ? What am I doing wrong here ?  :-/




Well I had mentioned in my first post that the Property references in here are case-sensitive and I don't know why it is the way it is. #-o

Work Around is put the property names exactly as they appear when we did this $Members | Get-Member  (Note below the proper case of the Property Names)




This issue has been fixed in the new R2 CU1  :-$

Now back to what we are doing. With PowerShell there are lot of things which you can do like sort on basis of LastMPServerName property and then group the devices having same LastMPServerName property :



Endless possibilities -- You can create a CSV of this report, an HTML report etc.

The only problem with this cmdlet is it doesn't allow me to specify a subset of the properties I want back, it just gives me back the whole set. So if there are lot of members in a collection it might take a while to run the cmdlet. Here is where the WMI way will be a bit efficient.

Using WMI/CIM we can specify the properties we want back using the WQL Query hence more efficient. I will be showing this in the next post as I have observed my posts length is increasing day by day...need to break it in pieces.

Till then /bye

Popular posts from this blog

Test connectivity via a specific network interface

Recently while working on a Private cloud implementation, I came across a scenario where I needed to test connectivity of a node to the AD/DNS via multiple network adapters.  Many of us would know that having multiple network routes is usually done to take care of redundancy. So that if a network adapter goes down, one can use the other network interface to reach out to the node. In order to make it easy for everyone to follow along, below is an analogy for the above scenario: My laptop has multiple network adapters (say Wi-Fi and Ethernet) connected to the same network. Now how do I test connectivity to a Server on the network only over say Wi-Fi network adapter?

PowerShell + SCCM : Run CM cmdlets remotely

Today I saw a tweet about using implicit remoting to load the Configuration Manager on my machine by Justin Mathews . It caught my eye as I have never really tried it, but theoretically it can be done. Note - The second tweet says "Cannot find a provider with the name CMSite", resolution to which is in the Troubleshooting section at the end.

Azure DevOps Tips & Tricks - Find private REST APIs

Original source -  Azure DevOps Tip - Find private APIs Often working with Azure DevOps, I hit a wall trying to automate some tasks but there are no REST API's made public yet. It was one of those task of automating creation of Environments in multi-stage YAML based pipelines in AzDO. Quick research reveals that this has been requested in uservoice  (please upvote). Let's see one of the very simple ways to discover some of these APIs.