воскресенье, 20 июня 2010 г.

Create incidents based on a CSV file

Today I needed to generate incidents based on a CSV file that a external system generated. There are a couple of different ways to do it, but one simple way is to use the Service Manager PowerShell cmdlets that Patrik wrote. In my example I have a CSV file that looks like

I then have a PowerShell script that looks like

The PowerShell script read the CSV file and generate one incident for each line. BF261F09-5FAD-EEA4-24CE-1DA889CEF381 is the LTValue for category ”Printing Problem”. For default list values you can use friendly name but for all custom values you need to use the GUID. To get the GUID you need to query the ServiceManager database. You can run the following query to find the GUID for Printing Problems.

SELECT [LTStringId]
,[LanguageCode]
,[ElementName]
,[LTValue]
FROM [ServiceManager].[dbo].[LocalizedText] WHERE LTValue LIKE '%Printing%'

Update: If you need to import incidents that includes "," in for example the description, add "" around the whole description part in the CSV file. For example Incident Title 11,"Description including a , 02 here",Medium,Medium,BF261F09-5FAD-EEA4-24CE-1DA889CEF381,System

Posted via web from contributor's posterous

Комментариев нет:

Отправить комментарий