Question

Je suis prêt à importer un blog WordPress vers SharePoint 2010. Quelqu'un at-il un importateur déjà construit? Sinon, je vais devoir construire mon propre.

Était-ce utile?

La solution

Autres conseils

Je sais que c'est vieux, mais j'étais aussi frustré, que personne ne l'avait fait auparavant. J'ai décidé d'écrire mon script de migration dans Powershell. Si vous avez besoin quelque chose comme ça à nouveau, essayer: http: // memyselfandbenchase.blogspot.de/2015/07/migrate-your-wordpress-blog-to.html

espère que cela aide quelqu'un d'autre.

Voici le script. Désolé qu'il est si longtemps.

#requires -version 3  
 <#  
 .SYNOPSIS  
  This script migrates a wordpress blog to a sharepoint blog.  
 .DESCRIPTION  
  This script migrates a wordpress blog to a sharepoint blog.  
  It is based on the xml export from wordpress. It then parses all the  
  posts, comments and categories. It changes all of the links and  
  uploads the files/images in the posts to the sharepoint library.  
  In order for this to work, the wordpress blog is expected to still be  
  reachable through the links in the export. The user names are preserved  
  as long as the users are also available in sharepoint. Otherwise, the  
  Post/comment is carried out as another defined user.  
 .PARAMETER   
  none  
 .INPUTS  
  none  
 .OUTPUTS  
  Saves uploads from wordpress in .\uploads  
 .NOTES  
  Version:    1.0  
  Author:     Benjamin Chase  
  Creation Date: 15 July 2015  
 .EXAMPLE  
  Migrate-Wordpress.ps1  
 #>  
 #----------------------------------------------------------[Declarations]----------------------------------------------------------  
 if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null)   
 {  
   Add-PSSnapin "Microsoft.SharePoint.PowerShell"  
 }  
 $sourceURL = "https://my.wordpress.blog"  
 $destinationURL = "https://my.sharepoint.server"  
 #Name of sharepoint lists  
 $postListName = "Posts"  
 $mediaListName = "Pictures"  
 $categoryListName = "Categories"  
 $commentsListName = "Comments"  
 #local folder to save files from source server  
 $uploadsFromSourceServer = ($PSScriptRoot + "\uploads")  
 $xmlFilePath = Get-ChildItem ($PSScriptRoot + "\*.*") -Include "*.xml" | foreach-object {$_.Fullname}  
 #This user is used for posts and comments if the imported account does not exist in sharepoint  
 #$defaultUser = $Web.EnsureUser((Get-SPFarm).DefaultServiceAccount.Name)  
 $defaultUser = $Web.EnsureUser("guest")  
 #-----------------------------------------------------------[Execution]------------------------------------------------------------  
 $regex = [System.Text.RegularExpressions.Regex]::Escape($sourceURL) + '(.*?)\/uploads\/(.*?)"'  
 $Web = Get-SPWeb $destinationURL  
 $postList = $Web.Lists[$postListName]  
 $mediaList = $web.Lists[$mediaListName]  
 $categoryList = $web.Lists[$categoryListName]  
 $commentsList = $web.Lists[$commentsListName]  
 # load it into an XML object:  
 $xml = New-Object -TypeName XML  
 $xml.Load($xmlFilePath)  
 foreach($wpPost in $Xml.rss.channel.item )  
 {  
 $newPost = $postList.Items.Add()  
 $newPost["Title"] = $wpPost.title  
 #see if user exists in sharepoint, otherwise post as farm admin  
 try{  
      $newPost["Author"] = $Web.EnsureUser($wpPost.creator.innertext)  
 }  
 catch{  
      $newPost["Author"] = $defaultUser  
 }  
 $newPost["Teaser"] = $wpPost.description  
 #Convert CDATA to string and replace newline with HTML Syntax  
 [string]$body = ($wpPost.Encoded | Foreach {"$($_.innertext)"}).replace("`n","<br/>")  
 #if upload folder does not exist, create it  
 if(!(Test-path $uploadsFromSourceServer)){  
      New-Item -Path $uploadsFromSourceServer -ItemType Directory | Out-Null  
 }  
 #Get all uploaded files and upload them to sharepoint library  
 try{  
      $body | select-string -pattern $regex -AllMatches | Foreach {$_.Matches} | ForEach-Object {   
           $fileURL =($_.Value).trim('"')  
           $filename = ($fileURL.Substring($fileURL.LastIndexOf("/") + 1))  
           try{  
                $webClient=new-object system.net.webclient  
                $webClient.downloadfile($fileURL, ($uploadsFromSourceServer +"\$($filename)"))  
                write-host "Downloading: " $filename  
           }  
           catch{  
                write-error "Error while processing: " $fileURL  
           }  
      }  
 }  
 catch{  
      write-error "Error while parsing content."  
 }  
 #Convert Urls to new server url for the pictures  
 $body = $body | % {$_ -replace ([System.Text.RegularExpressions.Regex]::Escape($sourceURL)+"(.*?)\/uploads\/\d{4}\/\d{2}\/"), "$($destinationURL)/Lists/$($mediaListName)/"}   
 $newPost["Body"] = $body  
 $pubDate = Get-Date -Date $wpPost.post_date  
 $newPost["PublishedDate"] = $pubDate  
 [Microsoft.SharePoint.SPFieldLookupValueCollection] $categoryValues = New-Object Microsoft.SharePoint.SPFieldLookupValueCollection  
 #If category exists and is a category and not a post tag then add it to post  
 foreach($wpCategory in $wpPost.category | Where-object{$_.domain -eq "category"}){  
      if($categoryList.items.name -notcontains $wpCategory.innertext){  
           write-host "Adding category: " $wpCategory.innertext -ForegroundColor green  
           $newCategory = $categoryList.Items.Add()  
           $newCategory["Title"] = $wpCategory.innertext  
           $newCategory.Update()  
           #Update list to get new items and select category from list  
           $categoryList.Update()  
      }  
      #get category  
      $category = $categoryList.items | Where-object {$_.Name -eq $wpCategory.innertext}  
      $categoryValues.Add($category.id)  
 }  
 $newPost["PostCategory"] = $categoryValues  
 $newPost.Update()  
 $postList.Update()   
 #Generate lookup value to reference the post  
 $postToComment = $postList.items | Where-object {$_.Title -eq $newPost["Title"]}  
 $postLookupValue = New-Object Microsoft.Sharepoint.SPFieldLookupValue($postToComment["ID"],$postToComment["Title"])  
 #Migrate existing comments  
 if($wpPost.comment){  
      foreach($wpComment in $wpPost.comment){  
           $newComment     = $commentsList.Items.Add()  
           #Use comment as title, but cut it off so it fits in the field, this is the standard behaviour in SP  
           if($wpComment.comment_content.innertext.length -gt 26){  
                $newComment["Title"] = $wpComment.comment_content.innertext.Substring(0,26) + "..."  
           }  
           else{  
                $newComment["Title"] = $wpComment.comment_content.innertext  
           }  
           #see if user exists in sharepoint, otherwise post as farm admin  
           try{  
                $newComment["Author"] = $Web.EnsureUser($wpComment.comment_author_email)  
                $newComment["Editor"] = $Web.EnsureUser($wpComment.comment_author_email)  
           }  
           catch{  
                $newComment["Author"] = $defaultUser  
                $newComment["Editor"] = $defaultUser  
           }  
           $newComment["Body"] = $wpComment.comment_content.innertext  
           $createdDate = Get-Date -Date $wpComment.comment_date  
           $newComment["Created"] = $createdDate  
           $newComment["Modified"] = $createdDate  
           $newComment["PostTitle"] = $postLookupValue  
           $newComment.Update()  
      }  
 }  
 }  
 #Upload Files from posts  
 $fileCollection = $mediaList.RootFolder.Files  
 $files = Get-ChildItem $uploadsFromSourceServer  
 foreach ($file in $files)  
 {  
   $stream = $file.OpenRead()  
   $uploaded = $fileCollection.Add($file.Name, $stream, $TRUE)  
   write-host "Uploaded: " $file.Name -ForegroundColor green  
   if ($stream) {$stream.Dispose()}  
 }  
 if ($web) {$web.Dispose()}  
Licencié sous: CC-BY-SA avec attribution
Non affilié à sharepoint.stackexchange
scroll top