$User = "admin@M365x086769.onmicrosoft.com" 
$Creds = Get-Credentials 
$AllSites = @() 
$AllSites | Export-Csv -Path C:\temp\AllSites.csv -NoTypeInformation -Force 
function Get-SPOSubWebs{  
    $Webs = $RootWeb.Webs  
    ForEach ($sWeb in $Webs)  
        Write-Output $sWeb 
        $SiteObject = [PSCustomObject]@{Site = $sWeb.Url } 
        $AllSites +=$SiteObject 
        Get-SPOSubWebs -RootWeb $sWeb -Context $Context  
Connect-SPOService -Url "https://M365x086769-admin.sharepoint.com" -Credential $Creds 
$Sites = Get-SPOSite -Limit All | Select Url 
foreach($Site in $Sites) 
    Set-SPOUser -Site $Site.Url -LoginName $Creds.UserName -IsSiteCollectionAdmin $true -Verbose 
    $credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Creds.UserName, $Creds.Password) 
    $ctx = New-Object Microsoft.SharePoint.Client.ClientContext($Site.Url) 
    $ctx.Credentials = $credentials 
    $Web = $ctx.Web 
    $SiteObject = [PSCustomObject]@{SiteUrl = $Web.Url } 
    $AllSites +=$SiteObject 
    Get-SPOSubWebs -RootWeb $Web -Context $ctx     
$AllSites | Export-Csv -Path C:\temp\AllSites.csv -NoTypeInformation -Force 
This script will list and export all SharePointOnline Site Collections and Sub Sites to a CSV.  The script uses SharePoint Online Management Shell and Client Side Object Model.  The user running the script must be the administrator or each site collection.  This is require to ensure you can by pass sites that use unique permissions.  Make sure you download the latest version of SharePoint Online Client Components for better performance.  Go to Dev.office.com to find the link to latest assemblies.