Tip #569: Migrate knowledgebase articles to Interactive Service Hub like a boss

If there is one bonus take away from the yesterday’s tip, it’s

existing KB functionality will soon be deprecated so it is advisable to transition to new KB as soon as possible.

So people started to ask, how to do that.


How to migrate KB article

Long version

Yes, some assembly is required. Good news, it’s not that difficult. As you may have noticed, I did develop some affection for the PowerShell as an ad-hoc developer’s tool.

Import-Module Microsoft.Xrm.Data.Powershell

$global:conn = Get-CrmConnection -InteractiveMode
# get the old articles
$articles = Get-CrmRecords `
   -EntityLogicalName kbarticle `
   -Fields * 
ForEach($a in $articles.CrmRecords) {

  # display the title

  # create the record
  $newrec = New-CrmRecord `
    -EntityLogicalName knowledgearticle `
    -Fields @{ "title" = $a.title; }

  # set the content if it exists
  if($a.content) {
    Set-CrmRecord `
     -EntityLogicalName knowledgearticle `
     -Id $newrec.Guid `
     -Fields @{"content" = $a.content}
  # publish the article if it was published
  if($a.statecode -eq "Published") {
    Set-CrmRecord `
     -EntityLogicalName knowledgearticle `
     -Id $newrec.Guid `
     -Fields @{"statecode" = `
	   New-CrmOptionSetValue -Value 3}

Like a boss meme

Share on FacebookTweet about this on TwitterShare on Google+

Leave a Reply

Your email address will not be published. Required fields are marked *