Click here to Skip to main content
16,017,907 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to export managed and crawled properties in xml file, and read these properties from the xml file from another server in the sharepoint farm enviornment.
Posted
Comments
[no name] 31-Jan-12 8:11am    
What properties? What version of SharePoint?

1 solution

XML
Function Export-SpSearchManagedProperties([string]$SearchServiceApp,[string]$filename){
#Use This to ignore the out of the box managed properties
$IgnoreMappings = @("AboutMe","Account","AccountName","AssignedTo","Author","BaseOfficeLocation","BestBetKeywords","CategoryNavigationUrl","CollapsingStatus","Colleagues","contentclass","ContentsHidden","ContentSource","ContentType","CreatedBy","Department","Description","DisplayDate","DocComments","DocId","DocKeywords","DocSignature","DocSubject","DuplicateHash","EMail","EndDate","ExcludeFromSummary","ExpirationTime","FileExtension","Filename","FirstName","FollowAllAnchor","HierarchyUrl","HighConfidenceDisplayProperty1","HighConfidenceDisplayProperty10","HighConfidenceDisplayProperty11","HighConfidenceDisplayProperty12","HighConfidenceDisplayProperty13","HighConfidenceDisplayProperty14","HighConfidenceDisplayProperty15","HighConfidenceDisplayProperty2","HighConfidenceDisplayProperty3","HighConfidenceDisplayProperty4","HighConfidenceDisplayProperty5","HighConfidenceDisplayProperty6","HighConfidenceDisplayProperty7","HighConfidenceDisplayProperty8","HighConfidenceDisplayProperty9","HighConfidenceImageURL","HighConfidenceMatching","HighConfidenceResultType","HitHighlightedProperties","HitHighlightedSummary","HostingPartition","ImageDateCreated","Interests","IsDocument","JobTitle","Keywords","LastModifiedTime","LastName","Location","Memberships","MetadataAuthor","MobilePhone","ModifiedBy","NLCodePage","Notes","OfficeNumber","OrgNames","OrgParentNames","OrgParentUrls","OrgUrls","OWS_URL","parentLink","PastProjects","Path","PictureHeight","PictureThumbnailURL","PictureURL","PictureWidth","PreferredName","Priority","PrivateColleagues","Pronunciations","Purpose","Rank","RankDetail","RankingWeightHigh","RankingWeightLow","RankingWeightName","Responsibilities","Schools","SecondaryFileExtension","ServerRedirectedURL","ServiceApplicationID","SipAddress","Site","SiteID","SiteTitle","Size","Skills","SocialTagTextUrl","SPSiteURL","StartDate","Status","Title","UrlDepth","urn:schemas.microsoft.com:fulltextqueryinfo:cataloggroup","urn:schemas.microsoft.com:fulltextqueryinfo:sourcegroup","urn:schemas-microsoft-com:office:office#Description","urn:schemas-microsoft-com:office:office#ows_CrawlType","urn:schemas-microsoft-com:office:office#ows_ListTemplate","urn:schemas-microsoft-com:office:office#Subject","urn:schemas-microsoft-com:office:office#Title","urn:schemas-microsoft-com:publishing:Category","urn:schemas-microsoft-com:publishing:CategoryTitle","urn:schemas-microsoft-com:sharepoint:portal:area:CategoryUrlNavi","urn:schemas-microsoft-com:sharepoint:portal:area:Path","UserName","UserProfile_GUID","WebId","WikiCategory","WorkEmail","WorkPhone","YomiDisplayName")
#Uncomment the line below and comment the line above to export everything.
#$IgnoreMappings = ""

$ManagedPropreties = Get-SPEnterpriseSearchMetadataManagedProperty -SearchApplication $SearchServiceApp
add-content $filename "<?xml version=`"1.0`"?>"
add-content $filename "<ExportedPropreties>"
foreach ($MP in $ManagedPropreties){
[bool] $test = $true
foreach ($name in $IgnoreMappings){
    if ($MP.Name -eq $name){
    $test = $false
    }
}
if ($test -eq $true){
    add-content $filename "<ManagedProprety>"
    add-content $filename "<Name>$($MP.Name)</Name>"
    add-content $filename "<ManagedType>$($MP.ManagedType)</ManagedType>"
    $Mappings = $MP.GetMappings()
        foreach ($Mapping in $Mappings){
            add-content $filename "<Mapping>"
            add-content $filename "<CrawledPropset>$($Mapping.CrawledPropset)</CrawledPropset>"
            $CP = $Mapping.CrawledPropertyName
            if ($CP.Contains(":") -eq $true){
                add-content $filename "<CrawledPropertyName>$($CP.SubString(1+$cp.lastindexof(":"),$cp.Length-$CP.LastIndexOf(":")-1))</CrawledPropertyName>"
            } else {
                add-content $filename "<CrawledPropertyName>$($cp)</CrawledPropertyName>"
            }
                        add-content $filename "<CrawledPropertyVariantType>$($Mapping.CrawledPropertyVariantType)</CrawledPropertyVariantType>"
            add-content $filename "</Mapping>"
        }
    add-content $filename "</ManagedProprety>"
}

}
add-content $filename "</ExportedPropreties>"
}

Export-SpSearchManagedProperties "Search Service" "ExportedProperties.xml"
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900