A while ago I have written a post about CSV Import of objects. Last time I was just mentioning about importing objects of specific classes. But what about importing objects of combination classes (aka type projections)? This would be the case if you for instance want to import a computer object (one class) and in the same step want to configure the primary user (wich is a relationship to another class). If this sounds interesting, read on.
So how does this work? The procedure is exactly the same as when importing regular classes objects. That means, we will use a CSV-file that holds the information about the objects we want to import. On the other side we use an XML-file that will be used to map the information from the CSV-file to specific attributes. So let’s say we want to import new computer objects and in the same step configure the primary user of the computer. For that we start with the XML-file.
First we have to make sure to select the correct type projection name, in this case “Microsoft.Windows.Computer.ProjectionType (instead of just a class as shown in the first Part). Because we are specifying a Projection, we need to specify the seed class, in this case the class “Microsoft.Windows.Computer”.
Where do you get this information from? There are several documents about that, but you can also find out yourself what the exact names of the projections and classes are by using Powershell with the smlets. There is a nice cmdlet called “get-scsmtypeprojection” that lists the available projections and also displays the seed classes.
So based on that information you are able to build the XML-file for the import. But for now, we only defined the properties of the computer class (the seed class). Because we also want to configure the Primary User attribute, we need to add some more fields to the XML-file that we can use to identify a user object.
Now we are ready to create the data file. Because we are now using Projections, the data file will contain values for two different classes. Make sure the order is exactly the one that was specified in the XML-file.
Now start the import process using the Service Manager Console. If the import was successful, the new computer object is created and the Primary User is specified.
Now we have to structure and just need to add more information to the files. One cool thing would be doing this automatically from an Excel document. If time permits I will write an article about that. Stay tuned.