Share via


PowerShell を使用してカスタム モデルによる処理を要求する

適用対象: ✓ すべてのカスタム モデル |✓すべての事前構築済みモデル

重要

Microsoft Syntex PowerShell コマンドレットとその他のすべての 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