List all OneDrive Sites – HTML report

I am sharing a quickly written script that we have created for our legal department as they want to know the onedrive URLS for everyone in the company.

This script collect all the onedrive urls and save it in HTML table under report folder.

Download the script zip from below link, extract it and update the ps1 file.(variables section)

https://gallery.technet.microsoft.com/scriptcenter/List-all-OneDrive-Sites-3c3f13cf

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

 

$onedrivetemplate = “SPSPERS#9”  #This is the template for  personel sites (onedrive sites)
$orgname = “labtest” #update the name of your o365 organization
##################################

 

Change the directory to Script directory and launch ListAllOnedriveSItes.ps1 (it will ask you  for credentials)

Note: Sharepoint online management shell is required for running this script.

Enter Sharepoint Online administrator Credentials.

 

It will start generating the URLS and save the HTML report.

 

You can use this script if you have the same requirement.

PowerShell

<#     
    .NOTES 
    =========================================================================== 
     Created with:     VS Code 
     Created on:       9/20/2018 1:46 PM 
     Created by:       Vikas Sukhija 
     Organization:      
     Filename:         ListAllOnedriveSItes.ps1 
    =========================================================================== 
    .DESCRIPTION 
       Get all one drive URLs 
#> 
#########Load function############################################### 
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 LaunchSPO 
{ 
    param 
    ( 
        $orgName, 
        $cred 
    ) 
     
    Write-Host "Enter Sharepoint Online Credentials" -ForegroundColor Green 
    $userCredential = $cred 
    Connect-SPOService -Url "https://$orgName-admin.sharepoint.com" -Credential $userCredential 
} 
 
Function RemoveSPO 
{ 
     
    disconnect-sposervice 
} 
 
##########################Load variables & Logs#################### 
$log = Write-Log -Name "process_Onedrive" -folder logs -Ext log 
$report = Write-Log -Name "Onedriveurls" -folder Report -Ext html 
 
$onedrivetemplate = "SPSPERS#9" 
$orgname = "labtest" 
 
$collection = @() 
 
##########Start Script main############## 
 
Start-Transcript -Path $log 
 
try 
    { 
        LaunchSPO -orgName $orgname 
    } 
    catch 
    { 
        write-host "$($_.Exception.Message)" -foregroundcolor red 
        break 
    } 
######################SPO Launched, now extract report####### 
Write-host "Start generating Onedrive Urls" -ForegroundColor Green 
$collection = Get-SPOSite -Template $onedrivetemplate -limit ALL -includepersonalsite $True | Select Owner,Title,Url 
Write-host "Finished generating Onedrive Urls" -ForegroundColor Green 
RemoveSPO 
############Format HTML########### 
$HTMLFormat = "<!--mce:0-->" 
################################ 
 
$collection | select  Owner,Title,Url | ConvertTo-HTML -Head $HTMLFormat -Body "<H2><Font Size = 4,Color = DarkCyan>Onedrive Site URLS</Font></H2>" -AS Table | 
Set-Content $report 
get-date 
Write-Host "Script finished" -ForegroundColor green 
Stop-Transcript 
######################################################################################

 

Thanks for downloading

Sukhija Vikas

http://SysCloudPro.com

Advertisements

One thought on “List all OneDrive Sites – HTML report

  1. Pingback: List all OneDrive Sites – HTML report | Cloud Computers Guide

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