Skip to main content

PowerShell + SCCM 2012 R2 : Extending Discovery; Create Custom DDRs


While working on the previous post on exploring Discovery methods with PowerShell I came across this awesome post on creating custom DDRs with PowerShell in ConfigMgr07.


The above post explains how to create custom DDRs using ConfigMgr SDK for ConfigMgr 07.

So I got tempted to immediately try it out in my ConfigMgr12 environment and found out that there exists another cool way shown by Adam Meltzer (using C#) in his blog to create DDRs in ConfigMgr12. So in this post will try to cover :
  • Create DDRs using COM Interface (DLL used : smsrgenctl.dll)
  • Create DDRs using the new DiscoveryDataRecordFile Object Interface (DLL used: Microsoft.ConfigurationManagement.Messaging.dll)
Note : Both the above DLLs are part of ConfigMgr 2012 SDK.

Create DDRs using COM Interface (DLL used : smsrgenctl.dll)

Tried loading the smsrgenctl.dll from PowerShell using Add-Type , System.Reflection.Assembly's LoadFrom Method which is supposed to load the dependencies.



Finally used the resgvr32.exe to load and it did work but it would show sometime that it was success but won't show up the ProgID in my registry


After the DLL is loaded is pretty Straight Forward to follow the post mentioned earlier. Below is the Code which I used it has comments explaining what each line does:


After this you will see the entry reflect in ConfigMgr Console:




Create DDRs using the new DiscoveryDataRecordFile Object Interface (DLL used : Microsoft.ConfigurationManagement.Messaging.dll )

If you look in the "Redistributables" folder for ConfigMgr 12 SDK there is a dll named 'Microsoft.ConfigurationManagement.Messaging.dll'. Following the post by Adam (which is in C#) I was able to do it in PowerShell. Below is the what the documentation says about the class DiscoverDataRecordFile which will be used:



Note that this supersedes the old COM Method we used to create the DDRs.


This one is actually easy. See the code below (comments explaining each step):



Now the proof:



So this is how you can extend discovery using PowerShell.....I find this one very cool. Now I can populate a lot of device entries in my SCCM environment for testing.

I happen to be one of the speakers at the First PowerShell Saturday Event in India [Bangalore] (March 8th, 2014) and would be speaking on my ConfigMgr + PowerShell Experiments. If you are around and interested then do drop by.
You can register for PowerShell Saturday Event here (limited seats) --> 
http://pssatindia.eventbrite.com



UPDATE:: There is a cmdlet in the CM2012 R2 PowerShell Module which does this job of creating DDRs for you Import-CMComputerInformation, came to knew about this while reading this post HERE 

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.