{"id":80745,"date":"2016-11-10T00:01:31","date_gmt":"2016-11-10T08:01:31","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/?p=80745"},"modified":"2019-02-18T09:10:21","modified_gmt":"2019-02-18T16:10:21","slug":"manage-sharepoint-online-site-collections-and-the-web-templates-with-powershell","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/manage-sharepoint-online-site-collections-and-the-web-templates-with-powershell\/","title":{"rendered":"Manage SharePoint Online site collections and the web templates with PowerShell"},"content":{"rendered":"<p><strong>Summary:<\/strong> PowerShell commands can\u00a0<span>manage site collections and the web templates that\u00a0create site collections.<\/span><\/p>\n<p>Christopher Weaver is a Microsoft Premier Field Engineer (PFE) who focuses on SharePoint and Office 365 solutions for large enterprise Premier customers. He has been doing PowerShell and SharePoint with Microsoft for nine years. In his spare time, he enjoys backpacking, hiking, kite surfing, and spending time with his kids and dog. You can follow him on his blog at <a target=\"_blank\" href=\"https:\/\/blogs.technet.microsoft.com\/christwe\/\">https:\/\/blogs.technet.microsoft.com\/christwe\/<\/a>.<\/p>\n<p>Hello All,<\/p>\n<p>As we prepare our SharePoint Online environment for migration, we will need to be able to manage site collections and the web templates we use to create those site collections.\u00a0 First, let\u2019s look at the available cmdlets in this category.<\/p>\n<p><strong>Get-SPOWebTemplate<\/strong> \u2013 Gets all site templates that are available, or you can get specific templates based on different parameters.\u00a0 In the example, we get the default Team Site web template.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/1-HSG-111016.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/1-HSG-111016.png\" alt=\"Result from Get-SPOWebTemplate\" width=\"614\" height=\"140\" class=\"alignnone size-full wp-image-80755\" \/><\/a><\/p>\n<p style=\"padding-left: 60px\"><code>Get-SPOWebTemplate -Name STS#0<\/code><\/p>\n<p><strong>Get-SPOSite<\/strong> \u2013 Gets one or more site collections. You could then take that object and pass it to another cmdlet or use its members.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/2-HSG-111016.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/2-HSG-111016.png\" alt=\"Result from Get-SPOSite\" width=\"693\" height=\"119\" class=\"alignnone size-full wp-image-80756\" \/><\/a><\/p>\n<p style=\"padding-left: 60px\"><code>Get-SPOSite https:\/\/mmr258720.sharepoint.com<\/code><\/p>\n<p><strong>New-SPOSite<\/strong> \u2013 Creates a new site collection. It has many parameters, so you can set several properties automatically at creation time.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/3-HSG-111016.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/3-HSG-111016.png\" alt=\"Result from New-SPOSite\" width=\"664\" height=\"29\" class=\"alignnone size-full wp-image-80765\" \/><\/a><\/p>\n<p style=\"padding-left: 60px\"><code>New-SPOSite -url https:\/\/mmr258720.sharepoint.com\/sites\/test1 -Owner admin@mmr258720.onmicrosoft.com -StorageQuota 26214400<\/code><\/p>\n<p><strong>Remove-SPOSite<\/strong> \u2013 Moves a site collection to the recycle bin to permanently delete the site collection. Before the site is permanently deleted, you need to run the <strong>Remove-SPODeletedSite<\/strong> command or wait approximately 90 days.\u00a0 During this time, the site collection will not count towards storage quotas.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/4-HSG-111016.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/4-HSG-111016.png\" alt=\"Result from Remove-SPOSite\" width=\"611\" height=\"84\" class=\"alignnone size-full wp-image-80775\" \/><\/a><\/p>\n<p style=\"padding-left: 60px\"><code>Remove-SPOSite https:\/\/mmr258720.sharepoint.com\/sites\/test1<\/code><\/p>\n<p><strong>Set-SPOSite<\/strong> \u2013 Allows you to set many different properties on an existing site collection.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/5-HSG-111016.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/5-HSG-111016.png\" alt=\"Result from Set-SPOSite\" width=\"648\" height=\"21\" class=\"alignnone size-full wp-image-80785\" \/><\/a><\/p>\n<p style=\"padding-left: 60px\"><code>Set-SPOSite https:\/\/mmr258720.sharepoint.com\/sites\/mr -lockstate NoAccess<\/code><\/p>\n<p><strong>Test-SPOSite<\/strong> \u2013 This command will run one or several different health rules and then return the results.<\/p>\n<p>This command <u>only<\/u> produces a report. It does not make any changes to your site.\u00a0 After you have reviewed the report and are comfortable with the repairs, then please run the <strong>Repair-SPOSite<\/strong> cmdlet, which I describe later.<\/p>\n<p>The site health rules are:<\/p>\n<table border=\"1\" width=\"100%\" cellpadding=\"10\">\n<tbody>\n<tr bgcolor=\"black\">\n<th><span style=\"color: white\">Rule name<\/span><\/th>\n<th><span style=\"color: white\">Rule ID<\/span><\/th>\n<\/tr>\n<tr bgcolor=\"beige\">\n<td>Conflicting Content Types<\/td>\n<td>befe203b-a8c0-48c2-b5f0-27c10f9e1622<\/td>\n<\/tr>\n<tr bgcolor=\"white\">\n<td>Customized Files<\/td>\n<td>cd839b0d-9707-4950-8fac-f306cb920f6c<\/td>\n<\/tr>\n<tr bgcolor=\"beige\">\n<td>Missing Galleries<\/td>\n<td>ee967197-ccbe-4c00-88e4-e6fab81145e1<\/td>\n<\/tr>\n<tr bgcolor=\"white\">\n<td>Missing Parent Content Types<\/td>\n<td>a9a6769f-7289-4b9f-ae7f-5db4b997d284<\/td>\n<\/tr>\n<tr bgcolor=\"beige\">\n<td>Missing Site Templates<\/td>\n<td>5258ccf5-e7d6-4df7-b8ae-12fcc0513ebd<\/td>\n<\/tr>\n<tr bgcolor=\"white\">\n<td>Unsupported Language Pack References<\/td>\n<td>99c946f7-5751-417c-89d3-b9c8bb2d1f66<\/td>\n<\/tr>\n<tr bgcolor=\"beige\">\n<td>Unsupported MUI References<\/td>\n<td>6da06aab-c539-4e0d-b111-b1da4408859a<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/6-HSG-111016.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/6-HSG-111016.png\" alt=\"Result from Test-SPOSite\" width=\"635\" height=\"233\" class=\"alignnone size-full wp-image-80786\" \/><\/a><\/p>\n<p style=\"padding-left: 60px\"><code>Test-SPOSite https:\/\/mmr258720.sharepoint.com<\/code><\/p>\n<p><strong>Repair-SPOSite<\/strong> \u2013 Will run the health tests from the <strong>Test-SPOSite<\/strong> command and, when possible, will automatically repair an issue.\u00a0 After the command finishes running, it will provide a report with results.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/7-HSG-111016.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/7-HSG-111016.png\" alt=\"Result from Repair-SPOSite\" width=\"575\" height=\"219\" class=\"alignnone size-full wp-image-80795\" \/><\/a><\/p>\n<p style=\"padding-left: 60px\"><code>Repair-SPOSite https:\/\/mmr258720.sharepoint.com<\/code><\/p>\n<p><strong>Upgrade-SPOSite<\/strong> \u2013 Performs site collection upgrade. By default, this will be build-to-build upgrade. However, on occasion it could become a version-to-version upgrade. In this case, you must run a health check in repair mode to ensure that the site collection can be upgraded.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/8-HSG-111016.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/8-HSG-111016.png\" alt=\"Result from Upgrade-SPOSite\" width=\"614\" height=\"38\" class=\"alignnone size-full wp-image-80805\" \/><\/a><\/p>\n<p>Upgrade-SPOSite https:\/\/mmr258720.sharepoint.com<\/p>\n<p>As we prepare to migrate, we must create the new site collection that we will be migrating to, so let\u2019s look at the cmdlets that will make this possible. The first cmdlet will be <strong>New-SPOSite<\/strong> because this is the command that will create the site collection. Let\u2019s look at the parameters we can use.<\/p>\n<p style=\"padding-left: 30px\"><strong>NOTE:<\/strong><em> If a site collection in the Recycle bin has the same URL, this cmdlet will fail with an error that looks like this.<\/em><\/p>\n<p style=\"padding-left: 30px\"><em>New-SPOSite : A site already exists at url <\/em><a href=\"https:\/\/tenant.sharepoint.com\/sites\/sitecollection\"><em>https:\/\/tenant.sharepoint.com\/sites\/sitecollection<\/em><\/a><\/p>\n<p style=\"padding-left: 30px\"><em>The solution is to restore from the Recycle bin or permanently delete the site collection.<\/em><\/p>\n<ul>\n<li>Url \u2013 This is a required parameter and represents the URL for your site collection. Make sure that the managed path is valid for your tenant.<\/li>\n<li>Owner \u2013 This is a required parameter and represents the user name of the owner. The Owner must be a valid user account in your tenant (This means no groups or distribution lists). The owner receives Full Control of the site collection. This user should receive some high-level training to insure he doesn\u2019t do undesired damage.<\/li>\n<li>StorageQuota &#8211; This is a required parameter and represents the maximum size in MB that the site collection will grow. This cannot exceed the tenant max and includes items like the Recycle bin.<\/li>\n<li>Template \u2013 This is an optional parameter, but I recommend that you set it ahead of time. If you don\u2019t set it, the first person to hit the site collection with the correct permissions will get to pick the Template for you. You can pick a valid template by running the <strong>Get-SPOWebTemplate<\/strong><\/li>\n<li>CompatibilityLevel \u2013 This is an optional parameter but, again, I recommend that you set this ahead of time.<\/li>\n<\/ul>\n<p>If you have been following my last few articles, you should now be able to connect to the SharePoint Online service, manage the tenant, and manage\/create site collections. The next step will be how to use the migration API. Watch for that next.<\/p>\n<p><strong>Ed Wilson<\/strong>\nMicrosoft Scripting Guy<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: PowerShell commands can\u00a0manage site collections and the web templates that\u00a0create site collections. Christopher Weaver is a Microsoft Premier Field Engineer (PFE) who focuses on SharePoint and Office 365 solutions for large enterprise Premier customers. He has been doing PowerShell and SharePoint with Microsoft for nine years. In his spare time, he enjoys backpacking, hiking, [&hellip;]<\/p>\n","protected":false},"author":596,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[568,641],"tags":[694,56,45],"class_list":["post-80745","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-hey-scripting-guy","category-windows-powershell","tag-christopher-weaver","tag-guest-blogger","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: PowerShell commands can\u00a0manage site collections and the web templates that\u00a0create site collections. Christopher Weaver is a Microsoft Premier Field Engineer (PFE) who focuses on SharePoint and Office 365 solutions for large enterprise Premier customers. He has been doing PowerShell and SharePoint with Microsoft for nine years. In his spare time, he enjoys backpacking, hiking, [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/80745","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/596"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=80745"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/80745\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=80745"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=80745"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=80745"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}