Updated: Import Computer Form v0.8 – Directly adding a User Device Affinity in ConfigMgr 2012

A few months ago I released the first public version of my Import Computer Form. I’ve had some nice feedback about it and also some good ideas for added functionality. This update will mainly be about three things:

  • Cleaning-up old code, by merging a few lines and adjusting some queries.
  • Adding error catching, by introducing an error provider for faulty input.
  • Adding functionality, by introducing an option to add a User Device Affinity/ Primary User.

Overview

These additions mean that this version gives the user the possibility to perform the following actions, without the need of access to and/ or a locally installed ConfigMgr console:

  • ImpoCompInfov08Fill in a Computer name.
  • Fill in a MAC Address.
  • Select an OS Deployment Collection.
  • Select a Primary User.
  • Import the Computer Information.
  • Add the User Device Affinity/ Primary User.
  • Close the form.

Inside information

CreaRelaWMII thought it might be nice to give some information about how easy it actually is to add this new functionality of adding a User Device Affinity/ Primary User. First start with looking for the class and the methods that hides the functionality that is needed. This can be done by, either browsing through WMI, or searching through the online reference on MSDN. As the screenshot shows, I like to use WMI Explorer. It also show that browsing to the class SMS_UserMachineRelationship reveals the method CreateRelationship, which again reveals its four parameters. For the exact information about the parameters it’s still necessary to look at MSDN. The “fun” part is that the input, of the parameters, is required in the order as shown in WMI. The order shown at the different MSDN articles is NOT the order needed as the input! After all the input is collected, the command line is “just” adding it all together in one Invoke-WmiMetod command, like this:

Invoke-WmiMethod -Namespace root/SMS/site_$($SiteCode) -Class SMS_UserMachineRelationship -Name CreateRelationship -ArgumentList @($ResourceID, 2, 1, $UserName) -ComputerName $SiteServer

Note: I used exactly the same way to change my method, for importing a machine, into a “one-liner”. This made it to an Invoke-WmiMethod for the class SMS_Site and the method ImportMachineEntry, like this:

Invoke-WmiMethod -Namespace root/SMS/site_$($SiteCode) -Class SMS_Site -Name ImportMachineEntry -ArgumentList @($null, $null, $null, $null, $null, $null, $MACAddress, $null, $ResourceName, $True, $null, $null) -ComputerName $SiteServer

Availability

As of today this updated version of my Import Computer Form is publicly available via the TechNet Galleries. Please let me know what you think of the tool.

>> Available via download here on the TechNet Galleries! <<

Share

5 thoughts on “Updated: Import Computer Form v0.8 – Directly adding a User Device Affinity in ConfigMgr 2012

  1. Hi Peter, just wondering if you have any suggestion to capture UDA if we are not using OSD to deploy OS to client as we are imaging it offline? And would like to feed this primary user info to SCCM once this new computer is online and communicating with SCCM.

  2. Basically, what we are trying to achieve is to allow any new computer that is joining to the domain for the first time to create the relationship between the device and primary user, so that all applications associated to this user will be deployed via SCCM to the device. And we wish to update this UDA information during the client build (not using SCCM OSD at the moment – using offline client build process currently) and feeding this UDA details to SCCM once it comes online and communicating with SCCM without having to wait for the user or SCCM to determine the primary device for a user.
    Currently, we already have the options to allow user to configure UDA via Application Catalog and enabling SCCM to capture UDA based on usage pattern.

Leave a Comment