SharePoint Management Done Successfuly with PowerShell

default post thumbnails

SharePoint Management is a big topic and, in all honesty, can cover a lot of spheres, even more-so now with the cloud. If you’ve worked with SharePoint, by now you’ve probably realized that there isn’t much you can do from the interface.

Don’t get me wrong, there are quite a few options in the Settings as well as the Central Administration and that’s not even counting features available on Office 365. But you can go a little further and manage SharePoint using PowerShell.

PowerShell and SharePoint Management Shell explained

If you’re working with anything in the Microsoft space these days, you’ll, without a doubt, hear about PowerShell.

Do you remember the Command Prompt on your computer? It allowed you to execute commands that weren’t always available in the interface of your Windows, but also allowed you to save and script them to run when you wanted.

PowerShell is essentially the same, but with a lot more power. You can type your commands there and see the results just like before. However, the benefit is that you can add your own “Shells” or set commands to enable the person using it to do more.

As an example, if you look at SharePoint as a product, Microsoft added SharePoint specific commands to the regular PowerShell (available on Windows Operating Systems) and calls these Management Shell. Enabling you, the user, to effectively manage SharePoint.

Even here at Sharegate, we created our own list of commands to help you script and schedule your actions and made them available in PowerShell. There’s really a lot we can do with PowerShell when we start to think about it, and not only for SharePoint management.

Get started with the SharePoint Management Shell

Once you know how it works, you realize that there isn’t much to it. I won’t go into much details of scripting or complex scenarios, but I want to show you what you can do.

If you want to learn PowerShell from the start, I recommend you check out this interesting guide that may help you get started.

To start managing your SharePoint, you’ll want to make sure you open the Management Shell and not just PowerShell, since the commands you need won’t be available.

SharePoint Management fundamentals

If you want to get an idea of what you can do, the SharePoint Management Shell comes with a few commands to helps you.

Get-Command -Module “Microsoft.SharePoint.PowerShell”

This will give you the list of commands available for managing SharePoint. As you know, PowerShell can manage anything, so by limiting to the Management module, we can see what we can do.

Another way for you to get started and see what’s available, is to browse through the Index of Windows PowerShell cmdlets for SharePoint both On-Premises and Online. Combined with the built-in PowerShell ISE, you can probably get started quickly.

And of course, the PowerShell Command Builder is a fun way to get started building your commands if you like. But I’ll be honest, it’s more of something I found to be cool than useful.

Let’s begin with a simple notion like getting the Site Collections.


Simple enough, but how do I find out more information about these Site Collections? Your best friend is the Get-Member command that shows you what’s available in the current command you’re using.


You’ll see all the results show up, but their differentiator is the “Member Type” and in this case we’ll see some results as “Method” and some as “Property”. And that my friends, is how you unleash the power of the SharePoint Management Shell!

Essentially, “Methods” are what you can do to the object in your command and in this case it would be Site Collections we get from the result of Get-SPSite. For example, you can use the Delete method to delete the Site Collections returned.

Then you have “Property” that gives you the values for each of the possible properties of the object you asked for. Since we’re looking at Site Collections, we can see that there’s an “Owner” property that will return the Site Collection Owner of the results returned.

After that, it’s a matter of spending some time and exploring what’s available to see how you can apply your SharePoint Management rules and policies with PowerShell.

Manage your SharePoint Site Collections by first building an inventory

Manage SharePoint Site Collections by building an inventory

I’ve covered this before in an article that builds an inventory of SharePoint before a migration where I showed that we can export the information into Visio and build a diagram.

When we’re looking for complete SharePoint management capabilities, sometimes it can be as simple as getting the information we need out of SharePoint, building reports.

Get-SPWebApplication | Get-SPSite -Limit All | Get-SPWeb -Limit All | Select Title, URL, ID, ParentWebID | Export-CSV C:sharepointinventory.csv -NoTypeInformation

But as mentioned, we can literally go through the properties and get all the information we could ever want out of SharePoint.

Get-SPSite “” | Select-Object url, owner, @{Expression={$_.Usage.Storage}}, @{Expression={$_.Audit.AuditFlags}}, readonly, LastContentModifiedDate, @{Express={$_.QuotaStorageMaximumLevel}}

The command above will get me some pretty useful information on my Site Collection as well.

Another very important command to help you with your management is the Get-SPDeletedSite command to show you all deleted Site Collections and even recover them if you need to.

Site Collections without modified content for 12 months

Site Collections without modified content

To keep a clean environment, or just to stay on top of things, it could be interesting to see which Site Collections have nothing new or modified for the last 12 months. Once again, with the SharePoint Management Shell and a few lines and filters on the properties we see, we can get the results we need.

Get-SPSite -Limit All | Where-Object {$_.LastContentModifiedDate -le ((get-date).AddMonths(-12))} | select url, lastcontentmodifieddate

In this case, if the Site Collection’s Last Content Modified Date is less than today’s date minus 12 months, it’ll show up as one of the results. Do note that this property isn’t the best to build these kinds of reports however as the content may be modified by features or other things running in SharePoint.

You can even add the property “Owner” to the command above and have their names and emails show up so you can contact them and see if it’s ok to delete. Let’s change the “select” of the last command to the following:

select url, lastcontentmodifieddate, @{Expression={$}}, @{Expression={$}}

Find Lists and Libraries in SharePoint with versioning disabled

SharePoint Lists and Libraries with versioning disabled

One of the best features of SharePoint is its versioning in lists and libraries. Enabling users to view, compare and even restore a previous version of a document is great asset to document management.

Here’s a way to find out if there are any lists and libraries that do not have it enabled:

$sites.lists | Where {$_.enableversioning -eq $False} | select title, basetype, enableversioning, rootfolder, parentweb, parentweburl | sort parentweburl | Format-Table

The $sites variable essentially gets all the Sites within the Site Collections I want.

SharePoint Management with PowerShell takes time

If you have the time to sit down and explore all the Get-Member properties and methods available and test, I am convinced you will enjoy using it to manage your SharePoint. The examples above are but a few of the many possibilities offered when using this Management Shell.

Whether you want to build an inventory that includes details like storage and quota usage as well as who’s the owner or finding libraries with custom permissions, almost everything is possible.

The only downside I can see when using PowerShell to manage SharePoint is the time we have to invest when we are not familiar with it, or have that scripting or coding background.

What PowerShell commands do you use most often for your SharePoint Management tasks?

What did you think of this article?

Recommended by our team

Getting started is easy

Try ShareGate free for 15 days. No credit card required.

WEBINAR Get up to speed on SharePoint management best practices