Fix PowerShell Errors When Creating a SharePoint Subsite from a Custom Template
Question details
Create a SharePoint subsite from a custom web template using PowerShell without an UnexpectedToken parser error.

- 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.
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.
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.
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.
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.
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.
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.

Ask the SharePoint community for help with the command
Use this option if the parser error persists or the custom template is not available.
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.

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.




