Auteur de questions
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.
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
How do i use this exported csv now in order to import to scsm 2012?
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.
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.
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 :)
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.
$myIncidentProjection = get-scsmobjectprojection -projectionname "System.WorkItem.Incident.ProjectionType" -Filter "Id -eq 'IR15054'" [byte] $myByteArray = $myIncidentProjection.FileAttachment.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)
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.
- Proposé comme réponse Herb Winhoven jeudi 21 mars 2013 15:49
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.