web analytics


How to replicate Primary Device information from ConfigMgr to AD DS 2012

Posted by:

To replicate Primary Device information from ConfigMgr to AD DS 2012

  1. Identify the User Name.
  2. Query SMS_UserMachineRelationship WMI Class
  3. Set the msds-primarycomputer AD DS User property


Example Output

You can download the code examples from here


About the Author:

Kaido Järvemets is a developer, consultant, trainer specializing in Microsoft System Center Configuration Manager and PowerShell Solutions at Coretech. Kaido frequently speaks at European conferences and had his US debut as speaker at MMS April 2013. Kaido is well-known in the Configuration Manager communities where he’s a key player in the PowerShell game. Kaido host one of the most complete Configuration Manager PowerShell library’s in the world with hundreds of free code samples ready to download and implement – www.cm12sdk.net. Kaido has been awarded Microsoft Most Valuable Professional (MVP) in Microsoft Enterprise Client Management for his work with Configuration Manager from 2011 – to present. Kaido is the founder of System Center User Group Estonia in 2011.


  1. Paul W  December 27, 2013

    Thanks for the script. I am just now taking a look at using this to populate primary user. I think you may have a typo in this though for the $PrimaryDeviceQuery wmi query. Using the provided filter, it will pull all computers that a user has logged into. To get only the assigned primary computers, we need to add to the filter a Types=’1′ to get only the admin assigned primary computers. So the query would look like this:

    Get-WmiObject -Namespace “root\SMS\Site_$SiteCode” -Class SMS_UserMachineRelationship -Filter “UniqueUserName=’$UserName’ and ResourceClientType=’1′ and Types=’1′” -ComputerName $SiteServer


Add a Comment