Working with SharePoint Online Sites


Topic Last Modified: 2014-06-09

Summary: Use Windows PowerShell to Manage Office 365 using Windows PowerShell cmdlets, scripts, and batch processes.

Could we give you an example of a SharePoint Online related area that can be managed by using Windows PowerShell? Of course we can. One place where Windows PowerShell really shines is helping you identify a subset of your SharePoint Online sites. In larger organizations, it’s not uncommon to have scores of sites, maybe even hundreds or thousands of sites. Is there anything wrong with that? Of course not. But suppose you have several hundred sites and you want to know how many of those sites are wikis; in other words, you want to know how many of your sites are built using the Enterprise Wiki template (a template that, officially, has the name ENTERWIKI#0.) Can you find this information using the SharePoint Online Admin center? We won’t say that you can’t find this information that way, but it won’t be easy. And it definitely won’t be as easy as running this one Windows PowerShell command:

Get-SPOSite | Where-Object {$_.Template -eq "ENTERWIKI#0"}

In other words, we use the Get-SPOSite cmdlet to return information about all our sites, then use the Where-Object cmdlet to pick out only those sites where the Template property is equal to ENTERWIKI#0.

How did we know that the Enterprise Wiki template is officially named ENTERWIKI#0? That’s easy: we just ran this command:

Or maybe you’d like a list of all the sites that have a storage quota either greater than 1000 megabytes or less than 250 megabytes. Can you do that quickly and easily using Windows PowerShell? Of course you can:

Get-SPOSite | Where-Object {$_.StorageQuota -gt 1000 -or $_.StorageQuota -lt 250}

That’s a slightly more complicated query that some of the ones we’ve seen so far, but once you know the lingo you should have no problem understanding how it works. In this example, we’re looking for sites that meet 1 of 2 criteria. Either the site: 1) has a StorageQuota greater than (-gt) 1000 megabytes; or (-or), 2) has a StorageQuota less than (-lt) 250 megabytes. Suppose we have 4 sites:


Site StorageQuota

Site A


Site B


Site C


Site D


Using this sample date, Site A will be returned because it has a StorageQuota less than 250. Site D will also be returned, because it has a StorageQuota greater than 1000. Sites B and C don’t meet either criteria, so they will not be returned.

Here’s another one, just for fun. Suppose you’d like a list of all the sites that are not owned by administrator; that is, all the sites where the Owner is equal to someone other than, in our example, That command is so easy to write it’s almost embarrassing:

Get-SPOSite | Where-Object {$_.Owner -ne ""}

But just because it’s easy doesn’t mean it’s not useful, right?

Next: Working with SharePoint Online Users