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 {
$KBName=$_.ArticleId
If($_.EndUserContent -ne $null)
{
$br = new-object io.binaryreader $_.EndUserContent
$al = new-object collections.generic.list[byte]
while (($i = $br.Read()) -ne -1)
{
$al.Add($i)
}
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)
{
$al.Add($I)
}
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:
Abstract
AnalystContent
ArticleId
ArticleOwner
ArticleTemplate
ArticleType
AssetStatus
Category
Comments
CreatedBy
CreatedDate
DisplayName
EndUserContent
ExternalURL
ExternalURLSource
Keywords
Notes
ObjectStatus
PrimaryLocaleID
Status
Tag
Title
VendorArticleID
#Id
#Name
#Path
#FullName
#LastModified
#TimeAdded
#LastModifiedBy
EnterpriseManagementObject
RelationshipAliases
No comments:
Post a Comment