适用于: • 所有自定义模型 |• 所有预生成模型
重要
PowerShell cmdlet 和所有其他 PnP 组件都是开放源代码工具,由提供支持的活动社区提供支持。 官方Microsoft支持渠道提供的开源工具支持没有服务级别协议 (SLA) 。
自定义模型处理新上传到库的文件。 还可以在 UI 中手动请求处理。 但是,在某些情况下,通过 PowerShell 触发处理可能会更高效。
请求处理以前未分类的所有项
可以使用以下命令请求处理库中以前未分类的所有项:
#Note: you're connecting here to the site that holds the document library you want to process
Connect-PnPOnline -Url "https://contoso.sharepoint.com/sites/finance"
Request-PnPSyntexClassifyAndExtract -List "Documents"
对于较低优先级的处理,还可以考虑使用 -OffPeak 参数,该参数将文件排队,以便在租户所在的工作时间之外进行处理。 有关详细信息,请参阅 Request-PnPSyntexClassifyAndExtract。
请求处理库中所有项
可以请求处理库中的所有文件,即使它们以前已分类。 如果已更新模型或将另一个模型添加到库,则此步骤可能很有用。
#Note: you're connecting here to the site that holds the document library you want to process
Connect-PnPOnline -Url "https://contoso.sharepoint.com/sites/finance"
Request-PnPSyntexClassifyAndExtract -List "Documents" -Force
注意
使用包含超过 5,000 个项目的 -Force 选项会自动启用非高峰处理。
基于属性请求处理所有项
如果要将处理限制为库中特定项目子集,可以使用脚本选择特定的文件组。 在以下示例中,脚本允许选择字段和筛选依据的字段值。 可以使用 Get-PnPListItem 完成更复杂的查询。
#Note: you're connecting here to the site that holds the document library you want to process
Connect-PnPOnline -Url "https://contoso.sharepoint.com/sites/finance"
$list = Get-PnPList -Identity "Documents"
# Set the field name to filter items by
$fieldName = "Vendor"
# Set the field value to filter by
$fieldFilter = "Fabrikam"
$listItems = (Get-PnPListItem -List $list -fields $fieldName).fieldValues
$targetItems = $listItems | Where-Object -Property Provider -EQ -Value $fieldFilter
# Create a new batch
$batch = New-PnPBatch
# Add files to classify to the batch
foreach ($listItem in $targetItems) {
Request-PnPSyntexClassifyAndExtract -FileUrl $listItem.FileRef -Batch $batch
}
# Execute batch
Invoke-PnPBatch -Batch $batch
请求处理特定文件
还可以对特定文件请求处理。
#Note: you're connecting here to the site that holds the document library you want to process
Connect-PnPOnline -Url "https://contoso.sharepoint.com/sites/finance"
Request-PnPSyntexClassifyAndExtract -FileUrl "/sites/finance/documents/contoso contract.docx"
按文件模型的文件还支持批处理:
#Note: you're connecting here to the site that holds the document library you want to process
Connect-PnPOnline -Url "https://contoso.sharepoint.com/sites/finance"
# Create a new batch
$batch = New-PnPBatch
# Add files to classify to the batch
Request-PnPSyntexClassifyAndExtract -FileUrl "/sites/finance/documents/contoso contract.docx" -Batch $batch
Request-PnPSyntexClassifyAndExtract -FileUrl "/sites/finance/documents/relecloud contract.docx" -Batch $batch
# Execute batch
Invoke-PnPBatch -Batch $batch