Thursday, June 11, 2015

Export managed metadata

Get-SpServiceApplication | select DisplayName, ID
Get-SPServiceApplicationProxy | select DisplayName, ID
$mmsAppId = "GUID"
$mmsproxy = Get-SPServiceApplicationProxy -Identity GUID
Export-SPMetadataWebServicePartitionData -Identity $mmsAppId -ServiceProxy $mmsproxy -Path \\server\path\filename.bak

Migrate SharePoint social tag comments

Add-PSSnapin microsoft.sharepoint.powershell

$upaProxy = Get-SPServiceApplicationProxy GUID

$site = get-spsite #URL

$listName = #LISTNAME

foreach($web in $site.AllWebs){



$oldurl = ""

$newurl = ""

if($web.ParentWeb.Url -eq $site.url){



$list = $web.Lists[$listName]

$items = $list.items



foreach($item in $items)

{

if($item.xml -Like "*#RELPATH/PAGE.aspx, PAGETYPE*"){



$newurl = $web.url + "/" + $item.url

[System.uri]$newurl = $newurl

$newurl.AbsoluteUri



$oldurl = $newurl.AbsoluteUri

$oldurl = $oldurl -replace "SITE1", "SITE2"

$oldurl



Move-SPSocialComments -ProfileServiceApplicationProxy $upaProxy -OldUrl $oldurl -NewUrl $newurl.AbsoluteUri



}

}

}

}