How To Check and Set Channel Storage Space in Office 365 Video Portal using powershell

In this article we shall check how to get and set the storage space used by Office 365 Video.

Background:

Office 365 Video uses the SharePoint Online service. For every Office 365 Video Channel, a site collection is created in the SharePoint Online. This site collection is not visible by default in the admin central page. The URL for the new site collection will be in the below format.
https://<tenant-name>.sharepoint.com/portals/<channel-name>

The videos of the each channel will be in available in the below URL.

https://<tenant-name>.sharepoint.com/portals/<channel-name>/pVid

You can't manage the channel's site collection directly from the SharePoint Online portal.

 

Since each Office 365 Video Channel is a SharePoint Online site collection, it has the limitation of 1TB storage space and it occupies the storage quota available to the SharePoint Online tenant.

 

Currently the Office 365 Video adaption is quicker, so the admins needs to watch the storage space for each channel and there are situation to restrict the storage space for each channel.

 

The storage space used by each channel is not available in the Office 365 Video portal, only through SharePoint cmdlets(Get-SPOSite and Set-SPOSite) we can get and set the storage space. 

Get Office 365 Video channel's site collection:

Using the below search query we can get the Office 365 Video channels.

contentclass:sts_site WebTemplate:POINTPUBLISHINGTOPIC

Screenshot of the search result for the above search query.

Get the storage space used by the Office 365 Video Channel:

Using the previous setup, we have the URL for all the Office 365 Video Channel. Now we shall proceed getting the required information.

 

First we need to connect to the admin central using the cmdlet Connect-SPOService and then using the cmdlet Get-SPOSite, we retrieve the storage usage.

Note: All the storage usage values are in MB.

 

Now we shall export the storage usage of all the Office 365 Video channels to a CSV file using PowerShell.

function Invoke-RestSPO
{
        Param(
        [Parameter(Mandatory=$True)]
        [String]$AdminPortalUrl,
 
        [Parameter(Mandatory=$True)]
        [String]$SPOUrl,
 
        [Parameter(Mandatory=$False)]
        [Microsoft.PowerShell.Commands.WebRequestMethod]$Method = [Microsoft.PowerShell.Commands.WebRequestMethod]::Get,
 
        [Parameter(Mandatory=$True)]
        [String]$UserName,
 
        [Parameter(Mandatory=$True)]
        [String]$Password,
         
        [Parameter(Mandatory=$True)]
        [String]$CSV
         
        )
 
        Add-Type -Path ([System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client").location)
        Add-Type -Path ([System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.runtime").location)
     
    $SecurePassword = $Password | ConvertTo-SecureString -AsPlainText -Force
        $SPOQueryUrl= $SPOUrl + "/_api/search/query?querytext=%27contentclass:sts_site WebTemplate:POINTPUBLISHINGTOPIC%27&SelectProperties=%27Sitename%27&rowlimit=5000"
         
    Write-Host "Performing the SPO Search Query to get all the Office 365 Video Channels..." -ForegroundColor Green
        $request = [System.Net.WebRequest]::Create($SPOQueryUrl)
        $request.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName, $SecurePassword)
        $request.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f")
        $request.Accept = "application/json;odata=verbose"
        $request.Method=$Method
         
        $response = $request.GetResponse()
        $requestStream = $response.GetResponseStream()
        $readStream = New-Object System.IO.StreamReader $requestStream
        $data=$readStream.ReadToEnd()
         
        $results = $data | ConvertFrom-Json
        $N4result=$results.d.query.PrimaryQueryResult.RelevantResults.Table.Rows.results.Cells.results
        $Channels = @()
                    foreach($r in  $N4result){
                            If($r.Key -eq "SiteName")
                            {
                            $Channels +=$r.Value
                            }           
                        }
 
    $UserCredential = New-Object System.Management.Automation.PSCredential -argumentlist $UserName, $(convertto-securestring $Password -asplaintext -force)
 
    Write-Host "Collecting the Office 365 Video Channel Storage Details..." -ForegroundColor Green
        Connect-SPOService -Url $AdminPortalUrl -Credential $UserCredential
 
    $Channels|ForEach-Object{
 
        $channel=$_
 
        $site=Get-SPOSite -Identity $channel -Detailed
 
        New-Object -TypeName PSObject -Property @{
              channelname=$site.Title
              URL=$site.URL
             CurrentStorageinMB=$site.StorageUsageCurrent
             StorageQuotainGB=[Decimal]::Round($site.StorageQuota/1024)
             StorageQuotaWarningLevelinGB=[Decimal]::Round($site.StorageQuotaWarningLevel/1024)
              }
        }|select channelname,URL,CurrentStorageinMB,StorageQuotainGB,StorageQuotaWarningLevelinGB|export-csv -NoTypeInformation -path $CSV
         
}
 
$SPOAdminPortal=Read-Host "Enter SPO Admin Portal URL(https://<;domain>-admin.sharepoint.com):"
$SPOSiteURL=Read-Host "Enter SPO Portal URL(https://<;domain>.sharepoint.com):"
$CSVpath=Read-Host "Enter the CSV Path(c:\Storageresult.csv):"
 
Import-Module Microsoft.Online.SharePoint.Powershell 
 
$cred= Get-Credential
 
$result = Invoke-RestSPO -AdminPortalUrl $SPOAdminPortal -SPOUrl $SPOSiteURL -UserName $cred.UserName.ToString() -Password $cred.GetNetworkCredential().Password -CSV $Csvpath

In the above script

  1. First we are performing the SharePoint search to get the Office 365 Video Channels.
  2. Then using the cmdlet Get-SPOSite, we are retrieving the current storage used, allocated storage quota and storage quota warning level.

Below is the screen-shot of the generated CSV file with the storage quota details.

Setting the storage limitation for Office 365 Video channel:

To set the storage quota, we need to use Set-SPOSite cmdlet. To do this we need to ensure that "Site Collection Storage Management" is set to "Manual" in the admin central settings.

Using the below script, we can set the storage quota for all the channels through CSV.

function Invoke-RestSPO
{
        Param(
        [Parameter(Mandatory=$True)]
        [String]$AdminPortalUrl,
 
        [Parameter(Mandatory=$True)]
        [String]$SPOUrl,
 
        [Parameter(Mandatory=$False)]
        [Microsoft.PowerShell.Commands.WebRequestMethod]$Method = [Microsoft.PowerShell.Commands.WebRequestMethod]::Get,
 
        [Parameter(Mandatory=$True)]
        [String]$UserName,
 
        [Parameter(Mandatory=$True)]
        [String]$Password,
         
        [Parameter(Mandatory=$True)]
        [String]$CSV
         
        )
 
        Add-Type -Path ([System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client").location)
        Add-Type -Path ([System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.runtime").location)
     
    $SecurePassword = $Password | ConvertTo-SecureString -AsPlainText -Force
        $SPOQueryUrl= $SPOUrl + "/_api/search/query?querytext=%27contentclass:sts_site WebTemplate:POINTPUBLISHINGTOPIC%27&SelectProperties=%27Sitename%27&rowlimit=5000"
         
    Write-Host "Performing the SPO Search Query to get all the Office 365 Video Channels..." -ForegroundColor Green
        $request = [System.Net.WebRequest]::Create($SPOQueryUrl)
        $request.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName, $SecurePassword)
        $request.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f")
        $request.Accept = "application/json;odata=verbose"
        $request.Method=$Method
         
        $response = $request.GetResponse()
        $requestStream = $response.GetResponseStream()
        $readStream = New-Object System.IO.StreamReader $requestStream
        $data=$readStream.ReadToEnd()
         
        $results = $data | ConvertFrom-Json
        $N4result=$results.d.query.PrimaryQueryResult.RelevantResults.Table.Rows.results.Cells.results
        $Channels = @()
                    foreach($r in  $N4result){
                            If($r.Key -eq "SiteName")
                            {
                            $Channels +=$r.Value
                            }           
                        }
 
    $UserCredential = New-Object System.Management.Automation.PSCredential -argumentlist $UserName, $(convertto-securestring $Password -asplaintext -force)
 
        $csvValue = Import-Csv $CSV
        Write-Host "Started modifying the Office 365 Video Channel Storage Details..." -ForegroundColor Green
        Connect-SPOService -Url $AdminPortalUrl -Credential $UserCredential
         
                foreach ($line in $csvValue)  
                {
                        $StoragequotaGB=[convert]::ToInt64($line.StorageQuotainGB)*1024
                        $StorageQuotaWarningLevelGB=[convert]::ToInt64($line.StorageQuotaWarningLevelinGB)*1024
                        Set-SPOSite -Identity $line.URL -StorageQuota $StoragequotaGB -StorageQuotaWarningLevel $StorageQuotaWarningLevelGB
                        $site=Get-SPOSite -Identity $line.URL -Detailed
                                  Write-Host "Site Name                    : "   $site.Title -foregroundcolor Green 
                                  Write-Host "Site URL                     : "   $site.URL -foregroundcolor Green 
                                  Write-Host "CurrentStorageinMB           : "   $site.StorageUsageCurrent -foregroundcolor Green 
                                  Write-Host "StorageQuotainGB             : "   ($site.StorageQuota/1024) -foregroundcolor Green 
                                  Write-Host "StorageQuotaWarningLevelinGB : "   ($site.StorageQuotaWarningLevel/1024) -foregroundcolor Green 
                                  Write-Host
                                  Write-Host
                }
                 
}
 
$SPOAdminPortal=Read-Host "Enter SPO Admin Portal URL(https://<;domain>-admin.sharepoint.com):"
$SPOSiteURL=Read-Host "Enter SPO Portal URL(https://<;domain>.sharepoint.com):"
$CSVpath=Read-Host "Enter the CSV Path(c:\Storageresult.csv):"
 
Import-Module Microsoft.Online.SharePoint.Powershell 
 
$cred= Get-Credential
 
$result = Invoke-RestSPO -AdminPortalUrl $SPOAdminPortal -SPOUrl $SPOSiteURL -UserName $cred.UserName.ToString() -Password $cred.GetNetworkCredential().Password -CSV $Csvpath

I have also posted the script to get and set the Office 365 Video channel storage quota through CSV in the TechNet Gallery https://gallery.technet.microsoft.com/How-To-Set-Channel-Storage-27d1786a
http://c.statcounter.com/10882132/0/8c35e683/1/