Get Available App Templates in SharePoint 2013 (Preview)


I’m starting to dig deeper into SharePoint 2013 Preview, and one of the first things I wanted to do was poke around the Object Model using PowerShell. In doing so, I thought it would be nice to have a quick and easy PowerShell Function to grab all available app templates.

This is actually very simple and is basically identical to the code which would work in SP2010, we simply grab an SPWeb object and then grab the ListTemplates collection.

Here are two examples of how to run it…

This example gets ALL app templates in a web at URL http://sp2013:

Get-SPAppTemplate -WebUrl http://sp2013

This example gets the Asset Library template in a web at URL http://sp2013:

Get-SPAppTemplate -WebUrl http://sp2013 | Where-Object {$_.name -eq "Asset Library"}

Here is the function, which can be run in SP2013 to return all available app/list templates:

function Get-SPAppTemplate {
<#
.Synopsis
	This advanced PowerShell Function retrieves available app/list templates
	in a specified SharePoint Web.
.Description
	This advanced function retrieves an SPWeb object and retrieves all 
	ListTemplates in the collection. Optionally, you can use *-Object cmdlets
	to retrieve a specific template or to select specific fields.
.Example
	C:\PS>Get-SPAppTemplate -WebUrl http://<webUrl> | Where-Object {$_.name -eq "Asset Library"}
	
	This example searches for an App tepmlate with the name "Asset Library."
.Example
	C:\PS>Get-SPAppTemplate -WebUrl http://<webUrl>
	
	This example retrieves all app templates under the webUrl SPWeb.
.Notes
	Name: Get-SPAppTemplate
	Author: Ryan Dennis
	Last Edit: 9/11/2012
	Keywords: Get-SPWeb,Get-SPAppTemplate
.Link
	http://www.sharepointryan.com
 	http://twitter.com/SharePointRyan
#Requires -Version 3.0
#>
[CmdletBinding()]
Param(
[Parameter(Mandatory=$true)][System.String]$WebUrl
)
$Web = Get-SPWeb $WebUrl
$Web.ListTemplates
$Web.Dispose()
}
Advertisements

2 thoughts on “Get Available App Templates in SharePoint 2013 (Preview)

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s