{"id":227,"date":"2011-11-10T14:29:54","date_gmt":"2011-11-10T13:29:54","guid":{"rendered":"http:\/\/www.mysticslayer.com\/?p=227"},"modified":"2011-11-10T14:29:54","modified_gmt":"2011-11-10T13:29:54","slug":"powershell-return-spwebtemplatenamebywebtemplateid","status":"publish","type":"post","link":"http:\/\/www.mysticslayer.com\/?p=227","title":{"rendered":"Powershell: Return SPWebTemplateNameByWebTemplateId"},"content":{"rendered":"<p>Sometimes you it&#8217;s easy to script some stuff, and you redo some stuff. For example: You want to manually script your export-import action in SharePoint automatically.<\/p>\n<p>Something you need by importing the site is the webtemplate before you can start the import. So, what you can do before deleting the site is to extract the WebTemplateId. The WebTemplate in $web.Url is not sufficient, because it doesn&#8217;t translate the correct Configuration.<\/p>\n<p>So, what I&#8217;ve did is to use the WebTemplateId and get the according WebTemplate Name. And use it to create a SPSite.<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\nfunction Get-SPWebTemplateNameBySPWebTemplateId($WebTemplateId)\r\n{\r\n    $templates = Get-SPWebTemplate | Sort-Object &quot;Name&quot;\r\n    $templateValues | ForEach-Object {\r\n        if($_.ID -eq $WebTemplateId)\r\n            $templateName = $_.Name\r\n            return;\r\n    }\r\n    return $templateName\r\n}\r\n\r\n$templateName = Get-SPWebTemplateNameBySPWebTemplateId -WebTemplateId 53\r\n\r\nWrite-Host = $templateName\r\n\r\n<\/pre>\n<p>Above will return BLANKINTERNET#2<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes you it&#8217;s easy to script some stuff, and you redo some stuff. For example: You want to manually script your export-import action in SharePoint automatically. Something you need by importing the site is the webtemplate before you can start the import. So, what you can do before deleting the site is to extract the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[262,224,246],"tags":[],"class_list":["post-227","post","type-post","status-publish","format-standard","hentry","category-powershell","category-sharepoint-2010","category-sharepoint-foundation"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pe1EH-3F","_links":{"self":[{"href":"http:\/\/www.mysticslayer.com\/index.php?rest_route=\/wp\/v2\/posts\/227","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.mysticslayer.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.mysticslayer.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.mysticslayer.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.mysticslayer.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=227"}],"version-history":[{"count":1,"href":"http:\/\/www.mysticslayer.com\/index.php?rest_route=\/wp\/v2\/posts\/227\/revisions"}],"predecessor-version":[{"id":228,"href":"http:\/\/www.mysticslayer.com\/index.php?rest_route=\/wp\/v2\/posts\/227\/revisions\/228"}],"wp:attachment":[{"href":"http:\/\/www.mysticslayer.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=227"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.mysticslayer.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=227"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.mysticslayer.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=227"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}