powershell 这将设置给定参数的托管属性
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了powershell 这将设置给定参数的托管属性相关的知识,希望对你有一定的参考价值。
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
$xmlData = "<?xml version='1.0' encoding='utf-8'?>
<SearchConfiguration>
<ManagedProperties>
<ManagedProperty Type='1' Name='PRHTitle'>
<MapProperty MapCategory='SharePoint' MapName='ows_Title0' VariantType='31'/>
<MapProperty MapCategory='SharePoint' MapName='ows_Title' VariantType='31'/>
<MapProperty MapCategory='SharePoint' MapName='ows_Kind_x0020_of_x0020_Deficiency' VariantType='31'/>
</ManagedProperty>
<ManagedProperty Type='1' Name='PRHSerialNumber'>
<MapProperty MapCategory='SharePoint' MapName='ows_Title' VariantType='31'/>
<MapProperty MapCategory='SharePoint' MapName='ows_NUCIR' VariantType='31'/>
<MapProperty MapCategory='SharePoint' MapName='ows_Document_x0020_Serial_x0020_Numb' VariantType='31'/>
</ManagedProperty>
<ManagedProperty Type='4' Name='PRHEventDate'>
<MapProperty MapCategory='SharePoint' MapName='ows_Close_x0020_Date' VariantType='64'/>
<MapProperty MapCategory='SharePoint' MapName='ows_Completed_x0020_Date' VariantType='64'/>
<MapProperty MapCategory='SharePoint' MapName='ows_Date_x0020_Originated' VariantType='64'/>
<MapProperty MapCategory='SharePoint' MapName='ows_Event_x0020_Date' VariantType='64'/>
</ManagedProperty>
<ManagedProperty Type='4' Name='PRHDateIssued'>
<MapProperty MapCategory='SharePoint' MapName='ows_Open_x0020_Date' VariantType='64'/>
<MapProperty MapCategory='SharePoint' MapName='ows_Date_x0020_Original_x0020_Issued' VariantType='64'/>
<MapProperty MapCategory='SharePoint' MapName='ows_Date_x0020_Issued' VariantType='64'/>
<MapProperty MapCategory='SharePoint' MapName='ows_Start_x0020_Date' VariantType='64'/>
</ManagedProperty>
<ManagedProperty Type='1' Name='PRHFAOA'>
<MapProperty MapCategory='SharePoint' MapName='ows_I_x002e_D_x002e_' VariantType='31'/>
<MapProperty MapCategory='SharePoint' MapName='ows_FA_x0020_Tab' VariantType='31'/>
<MapProperty MapCategory='SharePoint' MapName='ows_FA' VariantType='31'/>
<MapProperty MapCategory='SharePoint' MapName='ows_FunctionalArea' VariantType='31'/>
</ManagedProperty>
</ManagedProperties>
</SearchConfiguration>"
$searchapp = Get-SPEnterpriseSearchServiceApplication $SearchAppName
Write-Host "Parsing XML" -BackgroundColor Green -ForegroundColor Yellow
[System.Xml.XmlDocument]$XmlDoc = [xml]$xmlData
# Add Managed Properties
$PropertyNodeList = $XmlDoc.SearchConfiguration.ManagedProperties
foreach ($PropertyNode in $PropertyNodeList.ManagedProperty)
{
Write-Host "Checking for existing property: $PropertyNode.Name" -BackgroundColor Green -ForegroundColor Yellow
if($mp = Get-SPEnterpriseSearchMetadataManagedProperty -SearchApplication $searchapp -Identity $PropertyNode.Name -ea "silentlycontinue")
{
$mp.DeleteAllMappings()
$mp.Delete()
$searchapp.Update()
}
$PropertyNode.Name
Write-Host "Creating property: $PropertyNode.Name.ToString()" -BackgroundColor Green -ForegroundColor Yellow
$metadataProperty = New-SPEnterpriseSearchMetadataManagedProperty -SearchApplication $searchapp -Name $PropertyNode.Name -Type $PropertyNode.Type -EnabledForScoping $True
$mp = Get-SPEnterpriseSearchMetadataManagedProperty -SearchApplication $searchapp -Identity $PropertyNode.Name
foreach($propertymap in $PropertyNode.MapProperty)
{
$SPMapCat = $propertymap.MapCategory
$SPMapName = $propertymap.MapName
$propertymap.MapName
Write-Host "Creating mappings" -BackgroundColor Green -ForegroundColor Yellow
$cat = Get-SPEnterpriseSearchMetadataCategory -SearchApplication $searchapp -Identity $SPMapCat
$prop = Get-SPEnterpriseSearchMetadataCrawledProperty -SearchApplication $searchapp -Category $cat -Name $SPMapName -VariantType $propertymap.VariantType
if($prop.IsMappedToContents -eq $false)
{
Write-Host "Setting Mapped to Content Property" -BackgroundColor Green -ForegroundColor Yellow
Set-SPEnterpriseSearchMetadataCrawledProperty -Identity $prop -IsMappedToContent $true
}
$newMappedProperty = New-SPEnterpriseSearchMetadataMapping -SearchApplication $searchapp -CrawledProperty $prop -ManagedProperty $mp
}
}
Write-Host "Done" -BackgroundColor Blue -ForegroundColor Yellow
$xmlData = "<?xml version='1.0' encoding='utf-8'?>
<SearchConfiguration>
<ManagedProperties>
<ManagedProperty Type='1' Name='IncidentReportTitle' MapCategory='SharePoint' MapName='ows_Title' VariantType='31'/>
<ManagedProperty Type='1' Name='IncidentReportNUCIR' MapCategory='SharePoint' MapName='ows_NUCIR' VariantType='31'/>
<ManagedProperty Type='4' Name='IncidentReportDateOriginalIssued' MapCategory='SharePoint' MapName='ows_Date_x0020_Original_x0020_Issued' VariantType='64'/>
<ManagedProperty Type='1' Name='IncidentReportDescription' MapCategory='SharePoint' MapName='ows_Description' VariantType='31'/>
<ManagedProperty Type='1' Name='SelfAssessmentTitle' MapCategory='SharePoint' MapName='ows_Title' VariantType='31'/>
<ManagedProperty Type='1' Name='SelfAssessmentSerialNumber' MapCategory='SharePoint' MapName='ows_Document_x0020_Serial_x0020_Numb' VariantType='31'/>
<ManagedProperty Type='4' Name='SelfAssessmentDateIssued' MapCategory='SharePoint' MapName='ows_Date_x0020_Issued' VariantType='64'/>
<ManagedProperty Type='1' Name='SelfAssessmentID' MapCategory='SharePoint' MapName='ows_I_x002e_D_x002e_' VariantType='31'/>
<ManagedProperty Type='1' Name='SelfAssessmentDescription' MapCategory='SharePoint' MapName='ows_Description' VariantType='31'/>
<ManagedProperty Type='1' Name='CATSTitle' MapCategory='SharePoint' MapName='ows_Title' VariantType='31'/>
<ManagedProperty Type='1' Name='CATSTitle0' MapCategory='SharePoint' MapName='ows_Title0' VariantType='31'/>
<ManagedProperty Type='4' Name='CATSCompletedDate' MapCategory='SharePoint' MapName='ows_Completed_x0020_Date' VariantType='64'/>
<ManagedProperty Type='4' Name='CATSStartDate' MapCategory='SharePoint' MapName='ows_Start_x0020_Date' VariantType='64'/>
<ManagedProperty Type='1' Name='CATSFATab' MapCategory='SharePoint' MapName='ows_FA_x0020_Tab' VariantType='31'/>
<ManagedProperty Type='1' Name='CATSDescription' MapCategory='SharePoint' MapName='ows_Description' VariantType='31'/>
<ManagedProperty Type='1' Name='eRDRTitle' MapCategory='SharePoint' MapName='ows_Title' VariantType='31'/>
<ManagedProperty Type='1' Name='eRDRKindofDeficiency' MapCategory='SharePoint' MapName='ows_Kind_x0020_of_x0020_Deficiency' VariantType='31'/>
<ManagedProperty Type='4' Name='eRDRDateIssued' MapCategory='SharePoint' MapName='ows_Date_x0020_Issued' VariantType='64'/>
<ManagedProperty Type='4' Name='eRDRDateOriginated' MapCategory='SharePoint' MapName='ows_Date_x0020_Originated' VariantType='64'/>
<ManagedProperty Type='1' Name='eRDRFA' MapCategory='SharePoint' MapName='ows_FA' VariantType='31'/>
<ManagedProperty Type='1' Name='eRDRDescription' MapCategory='SharePoint' MapName='ows_Description' VariantType='31'/>
<ManagedProperty Type='1' Name='NuclearCritiqueTitle' MapCategory='SharePoint' MapName='ows_Nuclear_x0020_Critique_x0020__x0' VariantType='31'/>
<ManagedProperty Type='4' Name='eRDRDateIssued' MapCategory='SharePoint' MapName='ows_Date_x0020_Issued' VariantType='64'/>
<ManagedProperty Type='4' Name='eRDREventDate' MapCategory='SharePoint' MapName='ows_Event_x0020_Date' VariantType='64'/>
<ManagedProperty Type='1' Name='eRDRFunctionalArea' MapCategory='SharePoint' MapName='ows_FunctionalArea' VariantType='31'/>
<ManagedProperty Type='1' Name='eRDRDescription' MapCategory='SharePoint' MapName='ows_Description' VariantType='31'/>
</ManagedProperties>
</SearchConfiguration>"
$searchapp = Get-SPEnterpriseSearchServiceApplication $SearchAppName
Write-Host "Parsing XML" -BackgroundColor Green -ForegroundColor Yellow
[System.Xml.XmlDocument]$XmlDoc = [xml]$xmlData
# Add Managed Properties
$PropertyNodeList = $XmlDoc.SearchConfiguration.ManagedProperties
foreach ($PropertyNode in $PropertyNodeList.ManagedProperty)
{
Write-Host "Checking for existing property: $PropertyNode.Name" -BackgroundColor Green -ForegroundColor Yellow
if($mp = Get-SPEnterpriseSearchMetadataManagedProperty -SearchApplication $searchapp -Identity $PropertyNode.Name -ea "silentlycontinue")
{
$mp.DeleteAllMappings()
$mp.Delete()
$searchapp.Update()
}
$PropertyNode.Name
Write-Host "Creating property: $PropertyNode.Name.ToString()" -BackgroundColor Green -ForegroundColor Yellow
$metadataProperty = New-SPEnterpriseSearchMetadataManagedProperty -SearchApplication $searchapp -Name $PropertyNode.Name -Type $PropertyNode.Type -EnabledForScoping $True
$mp = Get-SPEnterpriseSearchMetadataManagedProperty -SearchApplication $searchapp -Identity $PropertyNode.Name
$SPMapCat = $PropertyNode.MapCategory
$SPMapName = $PropertyNode.MapName
$PropertyNode.MapName
Write-Host "Creating mappings" -BackgroundColor Green -ForegroundColor Yellow
$cat = Get-SPEnterpriseSearchMetadataCategory -SearchApplication $searchapp -Identity $SPMapCat
$PropertyNode.MapName
$prop = Get-SPEnterpriseSearchMetadataCrawledProperty -SearchApplication $searchapp -Category $cat -Name $SPMapName -VariantType $PropertyNode.VariantType
if($prop.IsMappedToContents -eq $false)
{
Write-Host "Setting Mapped to Content Property" -BackgroundColor Green -ForegroundColor Yellow
Set-SPEnterpriseSearchMetadataCrawledProperty -Identity $prop -IsMappedToContent $true
}
$newMappedProperty = New-SPEnterpriseSearchMetadataMapping -SearchApplication $searchapp -CrawledProperty $prop -ManagedProperty $mp
}
Write-Host "Done" -BackgroundColor Blue -ForegroundColor Yellow
$xmlData = "<?xml version='1.0' encoding='utf-8'?>
<SearchConfiguration>
<ManagedProperties>
<ManagedProperty Type='1' Name='IncidentReportTitle' MapCategory='SharePoint' MapName='ows_Title'/>
<ManagedProperty Type='1' Name='IncidentReportNUCIR' MapCategory='SharePoint' MapName='ows_NUCIR'/>
<ManagedProperty Type='4' Name='IncidentReportDateOriginalIssued' MapCategory='SharePoint' MapName='ows_Date_x0020_Original_x0020_Issued'/>
<ManagedProperty Type='1' Name='IncidentReportDescription' MapCategory='SharePoint' MapName='ows_Description'/>
<ManagedProperty Type='1' Name='SelfAssessmentTitle' MapCategory='SharePoint' MapName='ows_Title'/>
<ManagedProperty Type='1' Name='SelfAssessmentSerialNumber' MapCategory='SharePoint' MapName='ows_Document_x0020_Serial_x0020_Numb'/>
<ManagedProperty Type='4' Name='SelfAssessmentDateIssued' MapCategory='SharePoint' MapName='ows_Date_x0020_Issued'/>
<ManagedProperty Type='1' Name='SelfAssessmentID' MapCategory='SharePoint' MapName='ows_I_x002e_D_x002e_'/>
<ManagedProperty Type='1' Name='SelfAssessmentDescription' MapCategory='SharePoint' MapName='ows_Description'/>
<ManagedProperty Type='1' Name='CATSTitle' MapCategory='SharePoint' MapName='ows_Title'/>
<ManagedProperty Type='1' Name='CATSTitle0' MapCategory='SharePoint' MapName='ows_Title0'/>
<ManagedProperty Type='4' Name='CATSCompletedDate' MapCategory='SharePoint' MapName='ows_Completed_x0020_Date'/>
<ManagedProperty Type='4' Name='CATSStartDate' MapCategory='SharePoint' MapName='ows_Start_x0020_Date'/>
<ManagedProperty Type='1' Name='CATSFATab' MapCategory='SharePoint' MapName='ows_FA_x0020_Tab'/>
<ManagedProperty Type='1' Name='CATSDescription' MapCategory='SharePoint' MapName='ows_Description'/>
<ManagedProperty Type='1' Name='eRDRTitle' MapCategory='SharePoint' MapName='ows_Title'/>
<ManagedProperty Type='1' Name='eRDRKindofDeficiency' MapCategory='SharePoint' MapName='ows_Kind_x0020_of_x0020_Deficiency'/>
<ManagedProperty Type='4' Name='eRDRDateIssued' MapCategory='SharePoint' MapName='ows_Date_x0020_Issued'/>
<ManagedProperty Type='4' Name='eRDRDateOriginated' MapCategory='SharePoint' MapName='ows_Date_x0020_Originated'/>
<ManagedProperty Type='1' Name='eRDRFA' MapCategory='SharePoint' MapName='ows_FA' VariantType='1'/>
<ManagedProperty Type='1' Name='eRDRDescription' MapCategory='SharePoint' MapName='ows_Description'/>
<ManagedProperty Type='1' Name='NuclearCritiqueTitle' MapCategory='SharePoint' MapName='ows_Nuclear_x0020_Critique_x0020__x0'/>
<ManagedProperty Type='4' Name='eRDRDateIssued' MapCategory='SharePoint' MapName='ows_Date_x0020_Issued'/>
<ManagedProperty Type='4' Name='eRDREventDate' MapCategory='SharePoint' MapName='ows_Event_x0020_Date'/>
<ManagedProperty Type='1' Name='eRDRFunctionalArea' MapCategory='SharePoint' MapName='ows_FunctionalArea'/>
<ManagedProperty Type='1' Name='eRDRDescription' MapCategory='SharePoint' MapName='ows_Description'/>
</ManagedProperties>
</SearchConfiguration>"
$searchapp = Get-SPEnterpriseSearchServiceApplication $SearchAppName
Write-Host "Parsing XML" -BackgroundColor Green -ForegroundColor Yellow
[System.Xml.XmlDocument]$XmlDoc = [xml]$xmlData
# Add Managed Properties
$PropertyNodeList = $XmlDoc.SearchConfiguration.ManagedProperties
foreach ($PropertyNode in $PropertyNodeList.ManagedProperty)
{
Write-Host "Checking for existing property: $PropertyNode.Name" -BackgroundColor Green -ForegroundColor Yellow
if($mp = Get-SPEnterpriseSearchMetadataManagedProperty -SearchApplication $searchapp -Identity $PropertyNode.Name -ea "silentlycontinue")
{
$mp.DeleteAllMappings()
$mp.Delete()
$searchapp.Update()
}
$PropertyNode.Name
Write-Host "Creating property: $PropertyNode.Name.ToString()" -BackgroundColor Green -ForegroundColor Yellow
$metadataProperty = New-SPEnterpriseSearchMetadataManagedProperty -SearchApplication $searchapp -Name $PropertyNode.Name -Type $PropertyNode.Type -EnabledForScoping $True
$mp = Get-SPEnterpriseSearchMetadataManagedProperty -SearchApplication $searchapp -Identity $PropertyNode.Name
#foreach ($SharePointPropMap in $PropertyNode.Map)
#{
$SPMapCat = $PropertyNode.MapCategory
$SPMapName = $PropertyNode.MapName
$PropertyNode.MapName
Write-Host "Creating mappings" -BackgroundColor Green -ForegroundColor Yellow
$cat = Get-SPEnterpriseSearchMetadataCategory -SearchApplication $searchapp -Identity $SPMapCat
$PropertyNode.Type
$prop = Get-SPEnterpriseSearchMetadataCrawledProperty -SearchApplication $searchapp -Category $cat -Name $SPMapName
$newMappedProperty = New-SPEnterpriseSearchMetadataMapping -SearchApplication $searchapp -CrawledProperty $prop -ManagedProperty $mp
#}
}
Write-Host "Done" -BackgroundColor Blue -ForegroundColor Yellow
以上是关于powershell 这将设置给定参数的托管属性的主要内容,如果未能解决你的问题,请参考以下文章
powershell 这将获得特定的列表字段属性。使用问号的好例子?作为一个快捷方式。
powershell 从默认Search Service应用程序中删除所有托管元数据属性
如何托管 Powershell 脚本或应用程序以便可以通过 WSManConnectionInfo 访问它? (如 Office 365)
powershell 这将复制SharePoint网站。首先使用原始网站使用的相同模板制作空白网站。如果templa,这将失败
powershell 这将删除Web应用程序并离开内容数据库。这也是用于记录powershell a的PowerShell Transcripts的示例