Hi All,
In a recent deployment of SCCM 2012, I had a percentage of devices showing up under “Assets and Compliance” that did not have the SCCM client installed. Before troubleshooting each individual machine, I wanted to dump all machines showing up in “Devices” under Assets and Compliance” to a csv file. I needed the devices in a file so I could run other checks for example, to see if the machines were stale in Active Directory, if I could ping them etc… There may be other reasons you may need this information depending on your environment.
You will need to have the Configuration Manager Module for SCCM 2012 installed to run the following commands. The easiest way to load the Configuration Manager Module is to open the System Center Configuration Manager Console, click the arrow in the left corner and choose “Connect via Windows PowerShell” as shown below.
When PowerShell opens, you can type the following command to get all the devices in the SCCM 2012 console that do not currently have an agent installed and view the output in the PowerShell window (I will show you how to Export it to csv in a later example). In this example we are using the “Get-CMDevice” cmdlet and piping to the “Where-Object” cmdlet to say only choose machines where the “ClientType” property is empty or null. Depending on how many devices you have the time this may take to run will vary.
Get-CMDevice | Where-Object {$_.ClientType -eq $null}
After the command above completes you will see a list of the machines without the client and all the associated properties. As you can see, this may be too much information. In the example below I will select the 3 properties that I want to view (Name, DeviceOS, LatestProcessingAttempt) and export the information to a csv file using the Export-Csv cmdlet. I will export the information to a file named exportnoclient.csv in the c:\output directory. I add in the –NoTypeInformation parameter so we don’t get the type information at the top of the csv file.
Get-CMDevice | where-object {$_.ClientType -eq $null} |select Name,DeviceOS,LatestProcessingAttempt | Export-Csv c:\output\exportnoclient.csv –NoTypeInformation
After you run this command adding in the properties that you would like to see, you will have all the information in a file and you can open it in Excel or do whatever you would like with it. You could also manipulate this command to search for devices with other property settings. To get more information about the Get-CMDevice cmdlet you can simply type “Get-Help Get-CMDevice”. To get a list of other cmdlets available in the Configuration Manager PowerShell Module you can type the following with the module loaded:
Get-Command -Module ConfigurationManager
I hope this helps! If you have any questions or feedback, please leave a comment.
Related Links:
Using PowerShell to find Stale Computers in Active Directory