New-PnPSiteTemplateFromFolder

Tip

We encourage you to make improvements to this documentation. Please navigate to https://github.com/pnp/powershell/blob/dev/documentation/New-PnPSiteTemplateFromFolder.md to change this file.

Generates a provisioning template from a given folder, including only files that are present in that folder

Syntax

New-PnPSiteTemplateFromFolder
   [[-Out] <String>]
   [[-Folder] <String>]
   [[-TargetFolder] <String>]
   [-Match <String>]
   [-ContentType <ContentTypePipeBind>]
   [-Properties <Hashtable>]
   [[-Schema] <XMLPnPSchemaVersion>]
   [-AsIncludeFile]
   [-Force]
   [-Encoding <Encoding>]
    [-Connection <PnPConnection>]
   [<CommonParameters>]

Examples

EXAMPLE 1

New-PnPSiteTemplateFromFolder -Out template.xml

Creates an empty provisioning template, and includes all files in the current folder.

EXAMPLE 2

New-PnPSiteTemplateFromFolder -Out template.xml -Folder c:\temp

Creates an empty provisioning template, and includes all files in the c:\temp folder.

EXAMPLE 3

New-PnPSiteTemplateFromFolder -Out template.xml -Folder c:\temp -Match *.js

Creates an empty provisioning template, and includes all files with a JS extension in the c:\temp folder.

EXAMPLE 4

New-PnPSiteTemplateFromFolder -Out template.xml -Folder c:\temp -Match *.js -TargetFolder "Shared Documents"

Creates an empty provisioning template, and includes all files with a JS extension in the c:\temp folder and marks the files in the template to be added to the 'Shared Documents' folder

EXAMPLE 5

New-PnPSiteTemplateFromFolder -Out template.xml -Folder c:\temp -Match *.js -TargetFolder "Shared Documents" -ContentType "Test Content Type"

Creates an empty provisioning template, and includes all files with a JS extension in the c:\temp folder and marks the files in the template to be added to the 'Shared Documents' folder. It will add a property to the item for the content type.

EXAMPLE 6

New-PnPSiteTemplateFromFolder -Out template.xml -Folder c:\temp -Match *.js -TargetFolder "Shared Documents" -Properties @{"Title" = "Test Title"; "Category"="Test Category"}

Creates an empty provisioning template, and includes all files with a JS extension in the c:\temp folder and marks the files in the template to be added to the 'Shared Documents' folder. It will add the specified properties to the file entries.

EXAMPLE 7

New-PnPSiteTemplateFromFolder -Out template.pnp

Creates an empty provisioning template as a pnp package file, and includes all files in the current folder

EXAMPLE 8

New-PnPSiteTemplateFromFolder -Out template.pnp -Folder c:\temp

Creates an empty provisioning template as a pnp package file, and includes all files in the c:\temp folder

Parameters

-AsIncludeFile

If specified, the output will only contain the <pnp:Files> element. This allows the output to be included in another template.

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Connection

Optional connection to be used by the cmdlet. Retrieve the value for this parameter by either specifying -ReturnConnection on Connect-PnPOnline or by executing Get-PnPConnection.

Type:PnPConnection
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-ContentType

An optional content type to use.

Type:ContentTypePipeBind
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Encoding

The encoding type of the XML file, Unicode is default

Type:Encoding
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Folder

Folder to process. If not specified the current folder will be used.

Type:String
Position:0
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Force

Overwrites the output file if it exists.

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Match

Optional wildcard pattern to match filenames against. If empty all files will be included.

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Out

Filename to write to, optionally including full path.

Type:String
Position:0
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Properties

Additional properties to set for every file entry in the generated template.

Type:Hashtable
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Schema

The schema of the output to use, defaults to the latest schema

Type:XMLPnPSchemaVersion
Accepted values:LATEST, V201503, V201505, V201508, V201512, V201605, V201705, V201801, V201805, V201807, V201903, V201909, V202002
Position:1
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-TargetFolder

Target folder to provision to files to. If not specified, the current folder name will be used.

Type:String
Position:1
Default value:None
Accept pipeline input:False
Accept wildcard characters:False