Auto-CSV Import

Hello again Everyone!

I need to setup a method to automatically import CI's on a daily basis into SCSM. Our database team can take care of automating the CSV file creation and dumping it into a specified folder (e.g. C:\csv-to-import), but I have to take care of the SCSM end on my part.

What is the best way to go about doing this? Thanks in advance!

February 25th, 2015 4:47pm

The simplest method:

Create a Windows scheduled task that runs a powershell script on your management server that uses the following cmdlet: Import-SCSMInstance

A more interesting way of doing it:

http://blogs.technet.com/b/servicemanager/archive/2009/12/30/how-to-write-a-custom-connector-csv-connector-example.aspx


Free Windows Admin Tool Kit Click here and download it now
February 25th, 2015 5:08pm

Hello Aaron!

Thanks for your reply. I tried doing the second method, but when I finish configuring the connector and click "Create" it does not let me close the wizard.

Any ideas on how to fix this or should I just go about creating the script manually?


  • Edited by SirLearnAlot Wednesday, February 25, 2015 5:28 PM added snapshot
February 25th, 2015 5:23pm

Just a shot in the dark. Try enabling the finish button in the CSVConnectorResultPage.xaml.cs file by adding the following line after the FinishButtonText is set to "Close":

this.IsFinishButtonEnabled = true;

Did you check to see if the connector was actually created after you clicked Create on the Summary page?

Free Windows Admin Tool Kit Click here and download it now
February 25th, 2015 5:51pm

I downloaded the source from codeplex, added the line and recompiled. Replaced the Microsoft.Demo.Connectors.dll in the ServiceManager folder with the newly compiled one... still same problem.

Yes I checked to see if it was created anyways but nothing gets created... I am assuming it's waiting for me to click "Close" to act as a kind of confirmation before creating the connector.

February 25th, 2015 6:23pm

Have you stepped through the code yet? If you step through the code, you'll find the exception.

replace this line:

ManagementPack mpSubscriptions = emg.GetManagementPack("Microsoft.SystemCenter.Subscriptions", strSystemKeyToken, verSystemVersion);

with this one:

ManagementPack mpSubscriptions = emg.GetManagementPack("Microsoft.SystemCenter.Subscriptions", strSystemKeyToken, new Version("1.0.0.0"));
And make sure you enter file names into the data file path and mapping file path..you can't just enter a path.
Free Windows Admin Tool Kit Click here and download it now
February 25th, 2015 7:06pm

When I compile, shouldn't it bug out or produce an error if the code had an exception?

Curious, why are we using new Version ("1.0.0.0") instead of mpSystem.Version?

Ofcourse... I enter the paths correctly but when I click "Create", it changes my mapping file extension to .csv automatically... refer to screenshot for clarity.


When I click "Create" it's changed back to "csv"


  • Edited by SirLearnAlot Wednesday, February 25, 2015 7:36 PM
February 25th, 2015 7:35pm

It throws an exception, but the code uses MessageBox.Show which doesn't appear to work very well with this program. In other words, the MessageBox doesn't actually appear.

You can't use mpSystemVersion because the subscriptions MP has a different version number (a lower one). So why's it in this code? Back in 2010, every MP had the same version. So everyone who did any SCSM SDK code typically used the System.MPVersion as a quick painless trick to add that particular parameter. In 2012, the System MP version was higher than all the other MPs. So basically, it's a hold over from a convenient trick that no longer works. It caused headaches with more than one custom SCSM program back then..(mine included)

The only requirement to retrieve an MP is to have the name, the key (if applicable), and a version value that's less than or equal to the MPs version. MP versions like this are important if you're distributing MPs to multiple instances that may have different versions, but for your own MPs it's not quite as important (other than using the versions for your own organization and sanity). If you want to be perfectly precise, go get the subscription MP's version number from your database and use that instead of 1.0.0.0 :)

As for the csv, look at the Results xaml..both text boxes are bound to the DataFilePath..the second one should be bound to the MappingFilePath. It's just an aesthetic bug. It won't affect the creation of the connector..and if you got that far, the connector should have already been created..but it looks like your Close button is still greyed out? Make sure after you recompile and copy the dll you restart your console.

  • Marked as answer by SirLearnAlot Wednesday, February 25, 2015 8:32 PM
Free Windows Admin Tool Kit Click here and download it now
February 25th, 2015 8:21pm

Thanks Aaron! I got this working finally.

I recompiled, deleted the MP, re-added it and it works now. Awesome!

Thanks Again!

February 25th, 2015 8:37pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics