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:
If you scroll down enough you will see there is a property named lastmpservername and deviceos , so go ahead and do this
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
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:
- Easy Way : using cmdlet Get-CMDevice
- 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
$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