Exporting Microsoft Syntex Models
Microsoft Syntex models can be exported as PnP templates, enabling reuse across Content Centers or tenants.
Export all models in a Content Center
To export all models in a Content Center into a single PnP template, use the following PnP PowerShell cmdlets:
Connect-PnPOnline -Url "https://contoso.sharepoint.com/sites/yourContentCenter"
Get-PnPSiteTemplate -Out MyModels.pnp -Handlers SyntexModels
Export Specific Models
To export specific models from a Content Center into a PnP template, use the following PnP PowerShell cmdlets:
Connect-PnPOnline -Url "https://contoso.sharepoint.com/sites/yourContentCenter"
Get-PnPSiteTemplate -Out MyModels.pnp -Configuration .\extract.json
The extract.json defines which models you want to export, allowing to specify model by name or id and optionally configuring to not extract training data
Example- Specify model by name
{
"$schema": "https://developer.microsoft.com/en-us/json-schemas/pnp/provisioning/202102/extract-configuration.schema.json",
"persistAssetFiles": true,
"handlers": [
"SyntexModels"
],
"syntexModels": {
"models": [
{
"name": "Sample - benefits change notice.classifier"
}
]
}
}
Example- Specify model by id
{
"$schema": "https://developer.microsoft.com/en-us/json-schemas/pnp/provisioning/202102/extract-configuration.schema.json",
"persistAssetFiles": true,
"handlers": [
"SyntexModels"
],
"syntexModels": {
"models": [
{
"id": 3,
"excludeTrainingData": true
}
]
}
}
If you do not include the property "includeTrainingData", the default behavior is to include.
NOTE: training data is required for a model to be editable when imported to a destination Content Center
Export all models in a Content Center - individually as separate PnP templates
To export all models in a Content Center into individual PnP templates then use the following PnP PowerShell script.
Connect-PnPOnline -Url "https://contoso.sharepoint.com/sites/yourContentCenter"
$ExportPath = "C:\Syntex\ModelBackups"
$items = Get-PnPListItem -List 'Models'
foreach($item in $items)
{
if($item.FieldValues.ModelMappedClassifierName -ne $null)
{
Write-Output "Creating JSON Import File $ExportPath\$($item.FieldValues.ModelMappedClassifierName).json"
$jsonRepresentation = @"
{
"`$schema": "https://developer.microsoft.com/en-us/json-schemas/pnp/provisioning/202102/extract-configuration.schema.json",
"persistAssetFiles": true,
"handlers": [
"SyntexModels"
],
"syntexModels": {
"models": [
{
"name": "$($item.FieldValues.FileLeafRef)"
}
]
}
}
"@
$jsonRepresentation.Trim() | Out-File "$ExportPath\$($item.FieldValues.ModelMappedClassifierName).json"
Write-Output "Extracting Model $($item.FieldValues.ModelMappedClassifierName) to $($ExportPath)\$($item.FieldValues.ModelMappedClassifierName).pnp"
Get-PnPSiteTemplate -Out "$ExportPath\$($item.FieldValues.ModelMappedClassifierName).pnp" -Configuration "$ExportPath\$($item.FieldValues.ModelMappedClassifierName).json"
Write-Output "-----------------------------------"
}
}
This script will create the necessary JSON files for each model and then export each model as a separate .pnp file.