Wednesday, 22 May 2013

Service Manager - Exporting the Knowledge Base Analyst and End User Comments

How can I export my knowledge base articles from Service Manager?

I've heard this question asked a few times now, especially when it comes to doing a migration rather than an upgrade from 2010 to 2012.

While it's fairly straight forward to output things like the Article ID, Title, Category etc using PowerShell, getting the Analyst and EndUser comments out is slightly more tricky due to them being stored as binary data within the database (They're RTF files basically).

While I may update this post to give a script that will export every last detail I'm pushed for time at the moment so I'll just post the most complicated part.

You can use the following PowerShell script to export the comments to individual rtf files for both Internal and Analyst comments.

$OutDir = "C:\KnowledgeFolder"
Get-SCSMClass -DisplayName "Knowledge Article" | Get-SCSMClassInstance | ForEach-Object {
If($_.EndUserContent -ne $null)
$br = new-object io.binaryreader $_.EndUserContent
$al = new-object collections.generic.list[byte]
while (($i = $br.Read()) -ne -1)
Set-Content ("$OutDir\$KBName"+"EndUserContent.rtf") $al.ToArray() -enc byte
If($_.AnalystContent -ne $null)
$br = new-object io.binaryreader $_.AnalystContent
$al = new-object collections.generic.list[byte]
while (($i = $br.Read()) -ne -1)
Set-Content ("$OutDir\$KBName"+"AnalystContent.rtf") $al.ToArray() -enc byte

I've only had a quick test of this within a 2012 environment which has the native Get-SCSMClass and Get-SCSMClassInstance cmdlets whereas 2010 doesn't. 

However with the SCSM Cmdlets from CodePlex this script should be easily adaptable for the 2010 environment.

You could then use either PowerShell to import them back into a new environment, or use Anders CSV import method shown on his post here

Travis also has a useful post with the Enum GUID's that you would need when importing via CSV here

Some useful details for working with Knowledge Articles in PowerShell:

Class Details:
DisplayName - Knowledge Article
Name - System.Knowledge.Article
ManagementPackName - System.Knowledge.Library

Some of the array contents:


Anonymous said...

Hi. I used your cmdlet script to export the KBs and it worked great. Unfortunately, there is no xml file created that is needed for the CSV import. Is there a step that I missed or a line that needs to be added to your script to do this?

Steve Beaumont said...

Try my updated post:

That has a TechNet Gallery submission I did that has the script, example CSV file and the required XML file.


Kayal said...

I like this blog, this is a very simple but very good explanation about this useful topic. Well done and keep continuing...
Oracle Training in Chennai
Oracle Training institute in chennai
Social Media Marketing Courses in Chennai
Tableau Training in Chennai
Primavera Training in Chennai
Unix Training in Chennai
Oracle DBA Training in Chennai
Power BI Training in Chennai
Oracle Training in Chennai
Oracle Training institute in chennai

Reshma said...

Thanks for this wonderful blog it is really informative to all.keep update more information about this
Selenium Training in Chennai
Selenium Training in Bangalore
Selenium Training in Coimbatore
Best selenium training in chennai
Selenium Training Institute in Bangalore
Selenium Classes in Coimbatore
Ielts coaching in bangalore
German classes in bangalore

sasi said...

The concept you are saying is good. I was so happy after reading this article. Thankyou so much for good article.
web designing training in madurai
Web Designing Course in bangalore
web designing course in coimbatore
Web Designing Course in chennai
web designing training in madurai
Web Development courses in Chennai
Web development training in bangalore
salesforce training in bangalore

dhishageetha said...

Amazing Post. keep update more information.
Aviation Academy in Chennai
Air Hostess Training in Chennai
Airport Management Courses in Chennai
Ground Staff Training in Chennai
Aviation Courses in Chennai
Air Hostess Training Institute in Chennai
Airline Courses in Chennai
Airport Ground Staff Training in Chennai

Aishu said...

Superb. I really enjoyed very much with this article here. Really it is an amazing article I had ever read. I hope it will help a lot for all. Thank you so much for this amazing posts and please keep update like this excellent article.thank you for sharing such a great blog with us.

IELTS Coaching in chennai

German Classes in Chennai

GRE Coaching Classes in Chennai

TOEFL Coaching in Chennai

spoken english classes in chennai | Communication training