Skip to content

Instantly share code, notes, and snippets.

@rheid
Created March 16, 2014 17:08
Show Gist options
  • Save rheid/9586516 to your computer and use it in GitHub Desktop.
Save rheid/9586516 to your computer and use it in GitHub Desktop.
This script will allow show you the Crawled Property names and values for a Document. Using this information you can create Search Managed
#------------------------------------------------------------------------------------------------------
# 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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment