Hi @Alan Day
You could use this script:
Connect-SPOService -Url https://contoso-admin.sharepoint.com
$SiteURL = "https://crescent.sharepoint.com/sites/luyitest"
$ExportFile ="c:\ListRpt.csv"
Try {
#Get Credentials to connect
$Cred= Get-Credential
#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
#Get the web
$Web = $Ctx.web
$Ctx.Load($Web)
#get all subsites in sharepoint online powershell
$Ctx.Load($Web.Webs)
$Ctx.executeQuery()
$SubsiteCollection = @()
#Fetch each list item value to export to excel
$web.Webs | foreach {
$ExportItem = New-Object PSObject
$ExportItem | Add-Member -MemberType NoteProperty -name "Title" -value $_.Title
$ExportItem | Add-Member -MemberType NoteProperty -Name "url" -value $_.url
#Add the object with the above properties to the Array
$SubsiteCollection += $ExportItem
}
#Export the result Array to CSV file
$SubsiteCollection | Export-CSV $ExportFile -NoTypeInformation
Write-host -f Green "List data Exported to CSV file successfully!"
}
Catch {
write-host -f Red "Error:" $_.Exception.Message
}
As a result, you will get a csv file like this:
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.