SharePoint Online Site Collection owner Report

We have a requirement to extract sharepoint online owner report but it should exclude office 365 group sites and include only the sites that we are creating thru Sharepoint online administration control panel.

We can achieve this by excluding the site collections that are using the Template “Group#0”.

Download and extract the script zip file from below link.

https://gallery.technet.microsoft.com/scriptcenter/SharePoint-Online-fd31f576

Logs folder would contain script transcipt logs.

HTML report will be saved inside the Report folder.

Update the .ps1 script variables

########################################################

$log = Write-Log -Name “process_SpSiteonlineOwnerReport” -folder logs -Ext log

$output1 = Write-Log -Name “SPOCollection” -folder Report -Ext html

$orgname = “orgName”

$collection = @()

########################################################

Launch powershell from the computer where you have installed sharepoint online management shell (https://www.microsoft.com/en-us/download/details.aspx?id=35588)

It will ask you for your SP admin credentials.

Report will be generated as HTML and saved inside report folder.

Here is the glimpse of the report you will get.

 

Below is the powershell code….

PowerShell
<#     
    .NOTES 
    =========================================================================== 
     Created on:       8/17/2017 2:26 PM 
     Created by:       Vikas Sukhija 
     Organization:      
     Filename:         SpOnlineOwnerReport.ps1 
    =========================================================================== 
    .DESCRIPTION 
        This will report All owners of Sharepoint SItecollections 
#> 
#############Load Functions################# 
$error.clear() 
try { stop-transcript | out-null } 
catch { $error.clear() } 
 
function Write-Log 
{ 
    [CmdletBinding()] 
    param 
    ( 
        [Parameter(Mandatory = $true)] 
        [array]$Name, 
        [Parameter(Mandatory = $true)] 
        [string]$Ext, 
        [Parameter(Mandatory = $true)] 
        [string]$folder 
    ) 
     
    $log = @() 
    $date1 = get-date -format d 
    $date1 = $date1.ToString().Replace("/""-") 
    $time = get-date -format t 
     
    $time = $time.ToString().Replace(":""-") 
    $time = $time.ToString().Replace(" """) 
     
    foreach ($n in $name) 
    { 
         
        $log += (Get-Location).Path + "\" + $folder + "\" + $n + "_" + $date1 + "_" + $time + "_.$Ext" 
    } 
    return $log 
} 
 
function LaunchSHO 
{ 
    param 
    ( 
        $orgName, 
        $cred 
    ) 
     
    Write-Host "Enter Sharepoint Online Credentials" -ForegroundColor Green 
    $userCredential = $cred 
    Connect-SPOService -Url "https://$orgName-admin.sharepoint.com" -Credential $userCredential 
} 
 
Function RemoveSHO 
{ 
     
    disconnect-sposervice 
} 
##########################Load variables & Logs#################### 
$log = Write-Log -Name "process_SpSiteonlineOwnerReport" -folder logs -Ext log 
$output1 = Write-Log -Name "SPOCollection" -folder Report -Ext html 
$orgname = "OrgName" 
$collection = @() 
 
##########Start Script main############## 
 
Start-Transcript -Path $log 
try 
{ 
    LaunchSHO -orgName $orgname 
} 
catch 
{ 
    write-host "$($_.Exception.Message)" -foregroundcolor red 
    Send-MailMessage -SmtpServer $smtpserver -From $from -To $erroremail -Subject "SP Online ConnectionError Site owner Report" -Body $($_.Exception.Message) 
    break 
} 
 
$collection = Get-SPOSite -Filter { Template -ne "Group#0" } | where{ $_.url -like "*/sites/*" } | Select URL, Owner, StorageUsageCurrent, StorageQuota 
 
############Format HTML########### 
$HTMLFormat = "<!--mce:0-->" 
################################ 
 
$collection | ConvertTo-HTML -Head $HTMLFormat -Body "<H2><Font Size = 4,Color = DarkCyan>SharePoint Online Site Collection excluding Groups,Videos, OneDrive</Font></H2>" -AS Table | 
Set-Content $output1 
 
Stop-Transcript 
##############################################################################

 

Thanks for Downloading

Sukhija Vikas

http://SysCloudPro.com

Advertisements

6 thoughts on “SharePoint Online Site Collection owner Report

  1. You really make it seem really easy along with your presentation however I to find this topic to be really something that I believe I would by no means understand. It kind of feels too complex and extremely vast for me. I’m looking forward for your next publish, I will try to get the cling of it!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s