Others

Fix PowerShell Errors When Creating a SharePoint Subsite from a Custom Template

Algirdas JasaitisAlgirdas Jasaitis Nov 25, 2026 869 views

Question details

Create a SharePoint subsite from a custom web template using PowerShell without an UnexpectedToken parser error.

Fix PowerShell Errors When Creating a SharePoint Subsite from a Custom Template
Product
SharePoint Foundation 2013 and PowerShell
Device & OS
not provided
Scenario
An administrator is applying a custom web template to a new on-premises SharePoint subsite, potentially in a localized environment.
Observed behavior
PowerShell can report an UnexpectedToken parser error while processing the command.
Before you start

Run the commands in the SharePoint Management Shell on a SharePoint server with an account that has the required permissions. Have the full error message, the command, the custom template identifier, and the site language available.

Solution 1Recommended

Check the PowerShell syntax and custom template details

Use this approach to identify a parsing mistake before investigating template availability or language settings.

UnexpectedToken is a PowerShell parsing error. Check the syntax first; a localized SharePoint environment does not by itself establish the cause.

1
Inspect the reported line

In the SharePoint Management Shell, read the line and character position in the error. Check for missing quotes, unmatched parentheses or braces, and extra characters near the indicated token.

2
Check command syntax

Run Get-Command New-SPWeb -Syntax and Get-Command Get-SPWebTemplate -Syntax to see the parameters supported in your environment. Use Get-Help New-SPWeb -Full for further details.

3
Verify the template

Check the site collection's Solution Gallery to confirm that the custom template solution is available and activated. Use Get-Help Get-SPWebTemplate -Full to check how to list templates for the relevant site and language.

4
Retry with verified values

Edit the command in a plain-text editor, use straight quotation marks, and enter the exact template identifier and appropriate language value. Run the corrected command in the SharePoint Management Shell.

Check the PowerShell syntax and custom template details
Template availability: A template must be available in the relevant site collection and compatible with the target site and language. The exact identifier may differ from its displayed name.
Free Microsoft Office alternative

Work with Office documents in WPS Office

WPS Office is a free, lightweight alternative for working with Office documents in a familiar interface, making it easier to move everyday document work from Microsoft Office. It does not create SharePoint subsites or fix SharePoint PowerShell errors.

Edit documents, spreadsheets, and presentations in a familiar interfaceWork with Microsoft Office formats including DOCX, XLSX, and PPTXDocument SharePoint setup steps and troubleshooting notesUse a lightweight office suite for everyday tasks
microsoft office alternative - wps office

Frequently Asked Questions

What does UnexpectedToken mean in PowerShell?

It means PowerShell encountered text it could not parse in that position. Check the line and character shown in the error for incorrect quotes, brackets, parentheses, or extra characters.

How can I check the available New-SPWeb parameters?

In the SharePoint Management Shell, run Get-Command New-SPWeb -Syntax or Get-Help New-SPWeb -Full to review the syntax supported in your environment.

Where should I check whether the custom template is available?

Check the relevant site collection's Solution Gallery for the template solution and its activation status. Use Get-Help Get-SPWebTemplate -Full to review how to list templates for the site and language.

Can a localized SharePoint installation cause this error?

Language settings can affect which templates are available, but an UnexpectedToken error specifically points to a PowerShell parsing problem. Check command syntax first, then verify the template identifier and language.