Is there a way to find the properties of the site/web using Get-PnPPropertyBag by looping through a Hub site and associated sites? Get-PnPPropertyBag -Key MyKey only for one site properties, but I would like to iterate through sites on SPO and get properties to output into a CSV file..
Connect-PnPOnline -Url "https://mytenat-admin.sharepoint.us/"
#Getting the hub site id for which we want to generate the report - those are connected to this hub site.
$hubSiteURL="https://mytenatgov.sharepoint.us/sites/TargetSite"
$hubSite = Get-PnPTenantSite $hubSiteURL
$hubSiteId = $hubSite.HubSiteId
write-host " #####Generating sites connected a single hub site report######: " -BackgroundColor DarkGreen
write-host "Hub Site URL: " $hubSiteURL
$associatedSites = @()
#Get all sites associated to the hub site(in the above hub site)
$sitesTenant = Get-PnPTenantSite -Detailed
$sitesTenant | select url | % {$oneSite = Get-PnPTenantSite $_.url
if($oneSite.hubsiteid -eq $hubSiteId)
{
write-host "Associated Site URL: " $oneSite.url
$assocatedSiteObject = New-Object PSObject
$assocatedSiteObject | Add-Member -MemberType NoteProperty -name "HubSiteURL" -value $hubSiteURL
$assocatedSiteObject | Add-Member -MemberType NoteProperty -name "HubSiteID" -value $hubSiteId
$assocatedSiteObject | Add-Member -MemberType NoteProperty -name "Title" -value $oneSite.Title
$assocatedSiteObject | Add-Member -MemberType NoteProperty -Name "URL" -value $oneSite.Url
$assocatedSiteObject | Add-Member -MemberType NoteProperty -name "AssociatedStatus" -value $oneSite.Status
#Add the object with property to an Array
$associatedSites += $assocatedSiteObject
}
}
#Export the site array collection to a CSV file