none
Full solution to export and then import incidents

    Question

  • Can anyone provide a full solution of SMlets script to export the 100 most recent incidents from one system and then import them to my test server?

    We have special characters in the system like é, á, í, ó, so please take into account to use UTF8 format when exporting.

    I have just tried using this script:

             Get-SCSMIncident | export-csv "C:\EXPORT\INCINDENTS\Inc.csv"

    But it exported special characters as question mark (?) and it had this error also a few times:

              WARNING: Could not find enumeration: c4688f4f-eff8-4254-3d5f-90811ee53764

    So what I would like to see is a robust, error free SMlet script which would export and then import the most recent 100 incidents.

    Thanks!

    mercredi 11 avril 2012 10:05

Toutes les réponses

  • Export-Import incidents in production environment is a very COMPLEX task, and I don't think what someone will share that solution for-free.

    PS Using -Encoding parameter for export-csv allow to set UTF8 encoding:

    export-csv "C:\EXPORT\INCINDENTS\Inc.csv" -Encoding "UTF8"


    http://www.scsmsolutions.com/ freemanru (at) gmail (dot) com

    mercredi 11 avril 2012 10:21
    Modérateur
  • And can I import the CSV using the "CSV Connector" and a custom mapping file?
    mercredi 11 avril 2012 11:24
  • I did not read it till now, but the scsm 2012 upgrade Guide has a section: Setting Up a Service Manager 2010 Lab Environment with Production Data - maybe this document helps. But its real work ,)


    Patrick Wahlmüller

    mercredi 11 avril 2012 12:07
  • How do i use this exported csv now in order to import to scsm 2012?
    jeudi 19 avril 2012 17:15
  • How do i use this exported csv now in order to import to scsm 2012?

    Here you go: http://blogs.technet.com/b/servicemanager/archive/2009/05/26/using-the-csv-import-feature.aspx :)

    In this tutorial you'll find all the required information to create import data from a CSV file. Don't forget to download the AppendixA.html file to figure out the projections you may need.

    Cheers, Alex.

    mardi 12 juin 2012 08:43
  • can we export incident with analyst comment and analyst log.
    mardi 9 octobre 2012 08:53
  • can we export incident with analyst comment and analyst log.

    Yes that's possible with PowerShell. It depends on your requirements what you want to export how complex it gets though.

    I've already created a script for my custom purpose where I've exported comments from a custom incident class along with the incident ID, comment type, comment content, User who added comment and comment creation date into a CSV file.

    If you tell us some more about your requirements I may help you with a script if required.

    Cheers

    Alex

    mercredi 10 octobre 2012 12:07
  • can you please share the script

    Thanks

    lundi 29 octobre 2012 01:22
  • Hi

    Sorry for the delayed reply. Have missed this thread...

    You'll find the script here in the SMLets discussion forums on Codeplex.

    Please forgive me my fairly dumb approach creating a CSV like output. There are surely better and more efficient ways to accomplish this, but I was in a hurry at this time and had to do a PoC if we're able to export / import this kind of information. Apart from this I was quite new to SCSM and more sophisticated PowerShell scripting :) 

    Regards

    Alex

    vendredi 16 novembre 2012 12:45
  • Attachments are "ServerBinaryStreams" (a type defined in the SDK).

    Using SMLets, you can extract file attachments.

    I'll walk through the scenario I've recently tested

    I use SMLets "get-scsmobjectprojection" to grab incident projections. Included in the results are any files that happen to be attached. These file attachments can be accessed through the "FileAttachments" array. The Content property has a "data" byte array that you can write directly to a file using basic File IO in Powershell.

    Quick example:

    $myIncidentProjection = get-scsmobjectprojection -projectionname "System.WorkItem.Incident.ProjectionType" -Filter "Id -eq 'IR15054'"
    [byte[]] $myByteArray = $myIncidentProjection.FileAttachment[0].Content.Data
    [System.IO.File]::WriteAllBytes("c:\MyFile.txt",$myByteArray)
    
    

    All of the necessary file info (like extension, name, etc) are in the FileAttachment array elements..those array elements are just EnterpriseManagementObjects.

    Furthermore, regarding export/import.. the $myIncidentProjection can be used to grab the internal SDK XML Navigator..which you can use with an XSLT to create a CSV import definition, and you can use simple XQuery to extract all the data from the navigator to create your CSV import file. (To put it simply, you translate the InnerXML into the two files to do a CSV import)

    $myIncidentProjection.GetAsXML().CreateNavigator().InnerXML

    Everything about your incident (including any items related in the System.WorkItem.Incident.ProjectionType type projection) is included in that XML.

    At a very high level, this is what I've done in my environment to export and import incidents between environments. The only thing I haven't done programatically is import file attachments to another environment..I just haven't taken the time to figure out how to do that with the SDK, yet.

    jeudi 21 mars 2013 15:45
  • Alexander,

    That blog has a lot of good information but nowhere can I find what the syntax is for the Title and Description of an IR?  It's almost like you we import all of these IRs without titles no descriptions.

    jeudi 21 mars 2013 18:54
  • Herb,

    the syntax for other incident properties is exactly the same in the properties in the example word document in that blog post.

    Here's a link to a reference about almost all (if not all...) class properties: http://blogs.technet.com/b/servicemanager/archive/2009/05/26/appendix-a-to-previous-post.aspx

    This should help you to structure your mapping XML for the CSV import.

    BR

    Alex 

    lundi 25 mars 2013 12:12
  • Thanks, I would up finiding it on another post.  Oddly Appendix A lists very few properties.  I wish there was another doc out there that lists them all.

    lundi 25 mars 2013 13:54
  • Good stuff Aaron.

    I have pretty much worked it out using XML and the CSV import feature of SCSM but still cannot figure out how to import attachments.  I fear that this is not possible.

    lundi 25 mars 2013 13:57