Quantcast
Channel: Alex Pearce – BFC Networks
Viewing all articles
Browse latest Browse all 40

Office 365 SharePoint Online Admin PowerShell Cmdlet – With Samples

$
0
0

Office 365 and SharePoint Online is an ever growing and evolving cloud service  from Microsoft and in the migration to wave 15 of the Office product, Microsoft have released a set of PowerShell commands to manage your SharePoint Admin console.

Its important to note that these PowerShell commands are not the normal PowerShell commands you get for on-premise SharePoint and they are here to manage creating and managing site collection as well as gather information about your tenancy.

 

You can download the powershell commands from here

Here are a few powershell commands that you might find useful.

Import SharePoint Online Module

Import-Module Microsoft.Online.SharePoint.Powershell

Use this cmdlet to add the commands for SHarePoint Online management shell

Connection to SharePoint Online

We are first going to set the URL of the SharePoint Online Admin site and then log in.

Note we only have powershell for the admin portal so you have to connect to the –admin.sharepoint.com URL.

$spourl = “https://contoso-admin.sharepoint.com”

connect-sposervice -url $spourl

 

List all Site Collections

get-sposite

Get current storage of site collection

First we are going to get the Site Collection and request the information the current storage usage.

$spositecollection = get-sposite https://contoso.sharepoint.com

$spositecollection.StorageUsageCurrent

Average out Storage Quota to all Site Collections

This last command is a little bit more complicated.

We are going to get the storage quota for the tenancy and then divide that by the number of site collections we have an implement it to each site.  This command can take a while to run as it will run on each site collection, confirm and then move onto the next one.

#Gets the number of sites

$getnumberofsites = Get-SPOSite

$numbersofsites = $getnumberofsites.count


 

#get the storage quota for your tenancy

$gettenancy = Get-SPOTenant

$storagequota = $gettenancy.StorageQuota


 

#set average

$average = $storagequota / $numbersofsites


Get-SPOSite | foreach {Set-SPOSite -Identity $_.Url -StorageQuota $average}

This will now set each site collection to the average of the tenancy storage quota.  It will error if the average is over 100GB as this is the highest it can be.


Viewing all articles
Browse latest Browse all 40

Trending Articles