Bulk Get Site Info

Use PowerShell to get sites info.

# Define the paths
$path = $PSScriptRoot + "\"
$inputCsv = $path + "All-SPOs.csv"
$result = $path + "SitesUsage.csv"

# Import the sites from the input CSV file
$sites = Import-Csv -Path $inputCsv

# Initialize an array to hold site information
$siteInfo = @()

# Iterate through each site in the CSV
foreach ($site in $sites) {
    $url = $site.company
    $spoSite = Get-SPOSite -Identity $url -ErrorAction SilentlyContinue
    
    if ($spoSite) {
        $storageUsage = $spoSite.StorageUsageCurrent
        $title = $spoSite.Title
        $template = $spoSite.Template
        $owner = $site.Owner
        $groupId = $site.GroupId
        $hasTeams = $site.IsTeamsConnected
        $ModDate = $site.LastContentModifiedDate
        $siteInfo += [PSCustomObject]@{
            Title = $title
            Url = $url
            StorageUsage_MB = $storageUsage
            Template = $template
            Owner = $owner
            GroupID = $groupId
            HasTeams = $hasTeams
            LastModified = $ModDate
        }
    } else {
        Write-Warning "Site not found: $url"
    }
}

# Export the collected site information to a CSV file
$siteInfo | Export-Csv -Path $result -NoTypeInformation