Publish custom models with PowerShell

Applies to:   ✓ All custom models


The Microsoft Syntex PowerShell cmdlets and all other PnP components are open-source tools backed by an active community providing support for them. There is no SLA for open-source tool support from official Microsoft support channels.

Syntex models typically are deployed to document libraries across your tenant. This can be done by using the content center site, but this can also be done using PnP PowerShell as explained in this article.

Listing the available models in a content center

To get an overview of the models added to the current Syntex content center site, use the Get-PnPSyntexModel cmdlet:

Connect-PnPOnline -Url ""

Apply a model to a library

To apply a model to a library, use the Publish-PnPSyntexModel cmdlet:

Connect-PnPOnline -Url ""
Publish-PnPSyntexModel -Model "Contract Notice" -ListWebUrl "" -List "Documents"

Understanding where a model is used

Once you've deployed a model to many libraries, you might want to review the list of libraries using your model. This can be done using the Get-PnPSyntexModelPublication cmdlet:

Connect-PnPOnline -Url ""
Get-PnPSyntexModelPublication -Identity "Contract Notice"

Removing a model from a library

Removing a model from a library follows the same pattern as applying and can be done using the Unpublish-PnPSyntexModel cmdlet either interactively or as batch of multiple actions.

Connect-PnPOnline -Url ""
Unpublish-PnPSyntexModel -Model "Invoice model" -ListWebUrl "" -List "Documents"

Apply models in bulk

If you want to publish multiple models to multiple libraries, create an input CSV file listing the models and the target locations:

Contract Notice,,/sites/Site1,/sites/site1/shared%20documents
Contract Notice,,/sites/Site1,/sites/site1/other
Trade Confirmation,,/sites/Site2,/sites/site2/shared%20documents

This CSV file can then be used as an input into a script that will publish the listed models to the appropriate libraries. In the following example, batching is used to increase the efficiency of the requests.

$contentCenterURL = ""
$targetsCSV = "./Publish-SyntexModelBulk.csv"

Connect-PnPOnline -url $contentCenterURL

$targetLibraries = Import-Csv -Path $targetsCSV

$batch = New-PnPBatch

foreach ($target in $targetLibraries) {
    Publish-PnPSyntexModel -Model $target.ModelName -TargetSiteUrl $target.TargetSiteUrl -TargetWebServerRelativeUrl $target.TargetWebServerRelativeUrl -TargetLibraryServerRelativeUrl $target.TargetLibraryServerRelativeUrl -Batch $batch

Invoke-PnPBatch -Batch $batch