Bulk Publish Syntex Models To Libraries
This script sample will publish Syntex Document Understanding Models to many libraries using the batching functionality of PnP PowerShell.
Summary
This script sample will publish Syntex Document Understanding Models to many libraries using the batching functionality of PnP PowerShell. *Currently only document understanding models can be templated and rolled out to many sites
Implementation
- Create CSV file using the format supplied below and modify to reflect the values of your sites/libraries that you wish to deploy Syntex models to.
- Open Windows PowerShell ISE
- Edit Script and add required parameters for Syntex Content Center URL and path to CSV file
- Press run
###### Declare and Initialize Variables ######
#Change To Reflect Your Syntex Content Center
$syntexContentCenter = "https://contoso.sharepoint.com/sites/HRContentCenter"
#Path to CSV file
$csvFilePath = "Libraries.csv"
###### DO NOT EDIT BELOW THIS LINE #####
## log file will be saved in same directory script was started from
$saveDir = (Resolve-Path ".\")
$currentTime= $(Get-Date).ToString("yyyyddMMHHmmss")
$logFilePath=".\log-"+$currentTime+".log"
## Start the Transcript
Start-Transcript -Path $logFilePath
## Connect to your Syntex Content Center
Connect-PnPOnline -Url $syntexContentCenter -Interactive
## Import CSV file
$libraries = Import-Csv -Path $csvFilePath -Delimiter ";"
## Create a new batch
$batch = New-PnPBatch
foreach($lib in $libraries)
{
$splatCmds = @{
Model = $lib.Model
TargetSiteUrl = $lib.TargetSiteUrl
TargetWebServerRelativeUrl = $lib.TargetWebServerRelativeUrl
TargetLibraryServerRelativeUrl = $lib.TargetLibraryServerRelativeUrl
Batch = $batch
}
Publish-PnPSyntexModel @splatCmds
}
## Execute Batch - Add Syntex Model To Libraries
Invoke-PnPBatch -Batch $batch
## Disconnect the context
Disconnect-PnPOnline
## Stop Transcript
Stop-Transcript
Model;TargetSiteUrl;TargetWebServerRelativeUrl;TargetLibraryServerRelativeUrl
Aviation Incident Report;https://contoso.sharepoint.com/sites/Retail;/sites/Retail;/sites/Retail/shared%20documents
Refinement Rules Example;https://contoso.sharepoint.com/sites/SalesAndMarketing;/sites/SalesAndMarketing;/sites/SalesAndMarketing/shared%20documents
Contributors
| Author(s) |
|---|
| Leon Armston |
Disclaimer
THESE SAMPLES ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
Tool documentation & references
- Want to learn more about PnP PowerShell and the cmdlets
Check out the PnP PowerShell site to get started and for the reference to the cmdlets.