/SPOandOneDriveSiteAdminReportGenerator

Generates SharePoint and OneDrive site collection admin report

Primary LanguagePowerShell

SPO and OneDrive Site Collection Administrator Report Generator

Generates SharePoint and OneDrive site collection admin report

Written by Daniel, if you have any error, reach out to me on techjollof@gmail.com

Comment prove read by Christabel a SharePoint and OneDrive Expert

NO WARRANTY IS GUARANTEED. SAMPLE – AS IS, NO WARRANTY This script assumes a connection to SharePoint powershell.


SYNOPSIS

Generate SPO/OneDrive site collection administrators report

DESCRIPTION

You need to be a site admin to run the command Get-SPOUser. This script takes care of that work and removes the user after addding and getting the required information. The account used to connect-sposervice should serve as admin account.Account must GA or SPO admin

GlobalSPOAdminAddress

GlobalSPOAdminAddress is the address that will be granted OneDrive/SPO site collection admin permission, if permission does not exist, the command Get-SPOUser will generate error "Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))" This should be the address that runs Connect-SPOService. This is mandatory, if not provided, it will requested.

SiteAdminReportType

You can select type of report you want to generate, the values are OneDriveOnly, SharedChannelSiteOnly,PriviteChannelSiteOnly, CommunicationSiteOnly, AllTeamsSiteOnly, ParentTeamSiteOnly, ClassicSiteOnly..if this value is not specified, report will be generated for all SPO/OneDrive sites

How to use the this script

  • Donwload the folder and extract the content.

    E.g C:\Users\NAME\Download\SPOandOneDriveSiteAdminReportGenerator, this is equal to $Home\Downloads\SPOandOneDriveSiteAdminReportGenerator

  • Open PowerShell and cd (change directory) in the to the folder by typing the following
cd C:\Users\PNDT\Downloads\SPOandOneDriveSiteAdminReportGenerator
  • Connect to SPO powershell and replace TENANTNAME by your sharepoint admin name. Sign in the with the admin accont used GlobalSPOAdminAddress
    Connect-SPOService -Url https://TENANTNAME-admin.sharepoint.com
  • Then you run the script by the following

Example 1

This will generate report for all site in the sharepoint environment including OneDrive

   .\GetSPOandOneDriveSiteAdminReport.ps1 -GlobalSPOAdminAddress techjollof@constoso.com

Example 2

Getting all OneDrive sites only

   .\GetSPOandOneDriveSiteAdminReport.ps1 -GlobalSPOAdminAddress techjollof@constoso.com -SiteAdminReportType OneDriveOnly 

Result location

The report will be generated in the same folder where the script is location


Additional steps if the export file is empty but the powershell shows results

The exported csv is tested if its empty If the file is empty then Excel module is installed in the current user scope or context and results is exported as direct excel xlsx file. This section of the code will only run if the exported csv us empty

   Install-Module ImportExcel -AllowClobber -Force -Scope CurrentUser
   

For more information

Share, like and commend if you like it and foud it helpful