Möchte man die Zuordnung eines Primary Users automatisieren (statt die Zuordnung in der Admin Konsole vorzunehmen (“Edit Primary Users”)), so kann dafür entweder das Powershell-cmdlet Add-CMUserAffinityToDevice oder folgende vbs-Variante verwendet werden:
Set objSMS = GetObject("winmgmts://./root/sms/site_XYZ") ' Replace XYZ with the site code Set objUDA = objSMS.Get("SMS_UserMachineRelationShip") Set objRelShip = objUDA.Methods_("CreateRelationShip").inParameters.SpawnInstance_() objRelShip.MachineResourceID = "16777235" ' ResourceID objRelShip.SourceID = "2" ' AffinityType (2 = admin defined) objRelShip.TypeID = "1" objRelShip.UserAccountName = "your-domain\your-account" ' user account objSMS.ExecMethod "SMS_UserMachineRelationShip", "CreateRelationship", objRelShip