Yes, I know what you are thinking. Greg, what the @#$% are you talking about? For years, and via hundreds of blog posts, you have been telling us, the business users, to use SharePoint out of the box, to never utilize a single line of code, and now you are writing an article about PowerShell – the scripting language for IT geeks? First, let me calm you down. I am still a huge proponent of the out-of-the-box approach. However, throughout my almost 8 years of SharePoint Online consulting, I had situations where I had no choice but to utilize occasional PowerShell commands when working with client sites. So in this article, I would like to list the 5 commands I used most frequently that allowed me to achieve certain business requests by my clients or, on some occasions, save my butt! Let me summarize these frequent business scenarios and corresponding PowerShell commands for you.
1. Register a Home Site
This is a big one. If you want to convert your site into THE site of your corporate Intranet, the one that will define itself as the authoritative source of news, the site that will drive the navigation menu for the SharePoint App Bar, then you have got to register this site as a Home Site. Unfortunately, this is something that can only be done via PowerShell, not via the SharePoint Admin Center User Interface. Luckily, it is a pretty straightforward command, and I documented it for you here.
2. Upload a Custom Theme
“We need to brand SharePoint to match our brand.” If I had a dime every time I heard this phrase, I would not need to do any SharePoint consulting for a living 😊. Out of the box, there are only a few themes available for you to choose from. So if your Marketing folks don’t get excited about those, you would need to customize the colors further. Again, PowerShell to the rescue. While the theme code itself is developed using the alternate website, you would need to use PowerShell to install that Theme in your tenant. Again, I documented the process for you here.
3. Hard-delete a Team site
When you delete a Team Site, it goes to the SharePoint Admin Center Recycle Bin. It sits there for 93 days and then gets purged forever. However, out of the box, it can’t be deleted from that Recycle Bin manually. So if you need to reuse the same URL and distribution list email address for another Team Site, you would need to wait for 93 days for the site to be purged. However, with PowerShell, you can hard-delete a site in a matter of minutes. Please reference this post from Microsoft on the details of that command.
4. Free up a URL for Site Redirects when changing the Site URL
When you change the site URL via the SharePoint Admin Center, the site gets a new URL address. However, the old URL is still “functional” and redirects any traffic to the new URL (in the case of old links and bookmarks). What that means is that if you try to create a site with a given URL, it might complain to you that that the site address is not available (already taken), even though the site does not physically exist. That is most likely due to the site redirect and the URL being in existence at some point. So, in this case, if you would want to take over the old URL, you would need to disable the site redirect. And that can only be done via PowerShell. Please reference this other tutorial from Microsoft on how to do this.
5. Hub Commands
Hub registration and association are something that can be done in SharePoint Admin Center using the user interface. However, sometimes, as you register and unregister hub sites, you might end up with situations where it will not allow you to associate a site because it might think it is still a Hub, though it does not appear as such in the SP Admin UI. It is a bug. This does not have very often, but when it does, it is very annoying and can only be fixed via PowerShell. What you need to do is unregister the Hub Sites using PowerShell and clean up all of its associations. Here is a link to another Microsoft article that lists all the Hub-related PowerShell commands you would need.