CSV-Import of Objects using Type Projections

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”.

image

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.

image

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.

image

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.

image

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.

image

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.

regards
Marcel

This entry was posted in SCSM and tagged , , , , . Bookmark the permalink.

18 Responses to CSV-Import of Objects using Type Projections

  1. Hello Marcel.
    I was looking in your post trying to figure out how to do this but with a Relationship.
    I have a class extension of ChangeRequest with some new properties and a Relationship. Now I’m trying to do some magic to replicate the Work Items from the Production environment to the Development environment. So, I think that importing through the CSV connector is a way I can achieve that. Of course, I’m open to listen suggestions.
    I appreciate if you can help me with some ideas.
    Thank you.

  2. John says:

    Can you CSV import Service Request?

    • Hey

      Why do you want to import Service Requests?

      regards
      Marcel

      • John says:

        Hi Marcel,

        We are migrating our Access control process to Service Requests.

      • Hey

        OK, so why do you want to import them? Is it to document old, already fulfilled requests? If you want that, check out the CSV Import blog posts here, they explain the procedure …

        regards
        Marcel

      • John says:

        Thanks Marcel,

        Could you give me an example of the xml code used to import a Service request. Have you seen one? Been looking fro a while without any luck.

        Some XML lines would be great to know what projection class to select and how to choose a certain Service request template, as i have about 12 Service requests. eg i have an Access Request Service Request and Meeting Assistance Service request templates.
        When i use CSV what do i put in the xml to create an Access Request Service request instead of a Meesting assistance Service request, for example

        Regards

        John

  3. Pingback: SCSM: Using multiple key properties in classes | marcelzehner.ch

  4. Peter Stucki says:

    Hi Marcel,
    How do I configure Format File when I multiple *unrelated* classes. Eg. do I have to have multiple blocks?

    Here I have 1 Projection from the System.ConfigItem class.
    I also have my own custom class property.
    —————–

    —————————-
    Alas, I get this odd error that seems to indicate to me that I’m fundamentally misunderstanding something:
    —————————-
    Creating new CSVImporter

    Data Filename: D:\PeterMP\VirtualServerUpoload.csv
    Format Filename: D:\PeterMP\VirtualServerUpload-Format.xml

    Validating against XSD schema…
    The element ‘CSVImportFormat’ has invalid child element ‘Projection’.
    Validation completed.

    Expected one child node of type \”Component\” or \”Class\” under Component node

    Line number: 1, Position: 2
    Could not initialize a Management Object Creator from format file D:\PeterMP\VirtualServerUpload-Format.xml. Import thread exiting.
    ——————————-

    • Hey

      What do you mean with “unrelated classes”? If they are not related you can import them separately. If you have related classes you need to use Type Projections. If you send me your files with a short description I can take a quick look at it.

      Cheers
      Marcel

  5. Peter Stucki says:

    Thanks, your phrase “If they are not related you can import them separately” helped clear up a misconception of mine that, in turn, allowed me to solve my problem.
    Thanks!

    Regards,
    Peter

  6. Good to hear that Peter! Have fun importing things 🙂

    Cheers
    Marcel

  7. Peter Stucki says:

    Error: “Unknown alias SUS_WINDOWSCOMPUTER at node Component”
    I have extended the Windows.Computer class in the SCSM Authoring Tool to create the extended class SUS_WindowsComputer class. The Authoring Tool gave that extended class the name :

    Now I am trying to import via CSV into this extended class using the XML below, but I run into an error that I don’t know what I’m supposed to enter.

  8. Peter Stucki says:

    Here is the XML Format for the CSVImporter

    <Component Alias="SUS_WindowsComputer"

  9. Maekee says:

    Hi,
    Do you know how i add an object from type projection with powershell and not using a CSV-file?

    CSV imports and updates, but how do i remove with Type Projection? (Have two classes i want to remove instances from)

  10. packerphil says:

    Marcel,

    I am attempting to import/ update Unix and Linux Computer CI’s from a CSV file. What am I missing?
    —————————————————————-
    Example CSV pattern-
    Linux01.domain.com,Linux01.domain.com,hyper-v01.domain.com,Red Hat Enterprise Linux,7.1
    —————————————————————-

    My XML –

    —————————————————————-

    I am getting the following when I am trying to import the csv..

    Creating new CSVImporter

    Data Filename: D:\CSV_Import\TEST_Linux_Computers.csv
    Format Filename: D:\CSV_Import\Linux_Computers.xml

    Validating against XSD schema…
    Validation completed.

    Could not find property named OSVersionDisplayName in class UnixComputerExtension

    Line number: 13, Position: 14
    Could not initialize a Management Object Creator from format file D:\CSV_Import\Linux_Computers.xml. Import thread exiting.

    —————————————————————-

    As a note…

    OSVersionDisplayName is a property under the “Microsoft.Unix.ComputerHostsOperatingSystem” relationship type within the “UnixComputerExtension” class of the MP used.

    • packerphil says:

      I can’t post the XML….

      CSVImportFormat
      Projection Type=”Unix.Computer.Advanced”
      Seed
      Class Type=”Microsoft.Unix.Computer”
      Property ID=”PrincipalName” /
      Property ID=”DNSName” /
      Property ID=”HostServerName” /
      /Class
      /Seed
      Component Alias=”OperatingSystem”
      Seed
      Class Type=”UnixComputerExtension”
      Property ID=”OSVersionDisplayName”/
      Property ID=”OSVersion”/
      /Class
      /Seed
      /Component
      /Projection
      /CSVImportFormat

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s