Issue:

When creating Managed Properties in SharePoint Search it is difficult to find the exact name of the crawled property. This proves to be impossible in a very large environment as there can be hundreds of similarly named crawled properties.

Solution:

I have created a PowerShell script which will display all the crawled properties and values for a specific document.
The script accesses the SPListItem.Xml Property, this property contains all of the Items properties and their values.
This script is very valuable in troubleshooting as it shows you the exact value for each field as show in this blog: Error from SharePoint site: *** Index was outside the bounds of the array

Code:

The Script can be downloaded from the Microsoft Script Center Here Get-Crawled-Property-Names

#——————————————————————————————————

# Name:               Get-CrawledProperties.ps1

# Description:         This script will show you the crawled property names for a document library

# Usage:            Run the function with a Document  URL as the parameter.

# By:                 Ivan Josipovic, Softlanding.ca

#——————————————————————————————————

Function Get-CrawledPropertyNames([string]$DocURL){

$DocURL = $DocURL.Replace(“%20″,” “)

$webfound = $false

$weburl = $DocURL

 

while ($webfound -eq $false) {

if ($weburl.Contains(“/”)){

$weburl = $weburl.Substring(0,$weburl.LastIndexOf(“/”))

$web = get-spweb -identity $weburl -ea 0

if ($web -ne $null){

$webfound = $true

}

}else{

Write-Host -ForegroundColor Red “The Web could not be found”

return -1

}

 

}

$web.GetFile($DocURL).item.xml.Replace(“‘ “, “‘ `n”).Replace(“`” “, “`” `n”)

}

 

#To use enter the url of a file within a doucment library

Get-CrawledPropertyNames “http://sites/doc/file.pdf

If you have any questions please leave a comment.

Enjoy!

 

Written By:

Softlanding

More By This Author