Docteur L – François Lessard

SharePoint Architect, IT Manager and IT Specialist

Silverlight – Microsoft PowerShell Command Builder

Tags: , , , , ,

Microsoft release a very nice Silverlight tool to help you build any PowerShell Command for SharePoint Server, SharePoint Foundation or Office 365.

Check it out on Microsoft.com

Microsoft PowerShell Command Builder

Share on TwitterShare on LinkedInSubmit to StumbleUponDigg ThisSubmit to reddit
  • Author:
  • Published: Oct 14th, 2011
  • Category: Crawled Properties, Export, Import, Metadata Properties, PowerShell, Search engine
  • Comments: None
  •             

How to export Search Metadata Properties using PowerShell

Tags: , , ,

How to export Search Metadata Properties using PowerShell  from a Development (Test) Environment and import it in a Production Environment.

#Export Crawled Properties
$snapin = Get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.SharePoint.Powershell'}
 
if ($snapin -eq $null)
{
	Write-Host "Loading SharePoint Powershell Snapin"
	Add-PSSnapin "Microsoft.SharePoint.Powershell"
}
 
$CrawledPropertyName = "ows*"
$SearchService = "Search Service"
$PathXmlFiles = "C:\deploy\xml"
 
Get-SPEnterpriseSearchMetadataCrawledProperty -SearchApplication $SearchService | Where-Object {$_.name -like $CrawledPropertyName} | Export-Clixml $PathXmlFiles\getcrawledproperty.xml
 
Write-Host "Crawled Property exported to $PathXmlFiles\getcrawledproperty.xml" -ForegroundColor Yellow
 
#Import Crawled Properties
$snapin = Get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.SharePoint.Powershell'}
if ($snapin -eq $null)
{
	Write-Host "Loading SharePoint Powershell Snapin"
	Add-PSSnapin "Microsoft.SharePoint.Powershell"
}
$SearchService = "Search Service"
$PathXmlFiles = "\\(mydevserver)\C$\deploy\xml"
$xmlmetadata = Import-Clixml $PathXmlFiles\getcrawledproperty.xml
 
foreach ($metadata in $xmlmetadata)
{
	$created = Get-SPEnterpriseSearchMetadataCrawledProperty -SearchApplication $SearchService | Where-Object {$_.Name -eq $metadata.Name}
	if ($created)
	{
		Write-Host $metadata.Name "already present" -ForegroundColor:Yellow
	} else {
		New-SPEnterpriseSearchMetadataCrawledProperty -SearchApplication $SearchService -Name $metadata.Name -Category $metadata.CategoryName -PropSet $metadata.Propset -IsNameEnum:$false -VariantType $metadata.VariantType
		Write-Host $metadata.Name "added" -ForegroundColor:Yellow
	}
}
Share on TwitterShare on LinkedInSubmit to StumbleUponDigg ThisSubmit to reddit

© 2011 Docteur L – François Lessard. All Rights Reserved.

This blog is powered by Wordpress and Magatheme by Bryan Helmig.

Switch to our mobile site