Forum Discussion
fhunth
Jun 10, 2020Copper Contributor
Get-SPOSite how to get all sites on my tenant with a Sensitivity label = Highly Confidential?
Get-SPOSite how to get all sites on my tenant with a Sensitivity label = Highly Confidential? The Powershell command Get-SPOSite gets all sites on my Office 365 tenant. How could I filter all site w...
VasilMichev
Jun 10, 2020MVP
Use a filter against the SensitivityLabel property? It has to be a client-side filter though, via where-object, as the -Filter parameter doesn't seem to support the SensitivityLabel property.
fhunth
Jun 11, 2020Copper Contributor
I get this column with blank values. Get-SPOSite | select Url, SensitivityLabel
Url SensitivityLabel
--- ----------------
https://mycompany.sharepoint.com/sites/Test4531
https://mycompany.sharepoint.com/sites/TestSensi
https://mycompany.sharepoint.com/sites/Test41
Url SensitivityLabel
--- ----------------
https://mycompany.sharepoint.com/sites/Test4531
https://mycompany.sharepoint.com/sites/TestSensi
https://mycompany.sharepoint.com/sites/Test41
- VasilMichevJun 11, 2020MVP
Try using the -Detailed switch.
- fhunthJun 11, 2020Copper ContributorSame result. New Warning
PS C:\WINDOWS\system32> Get-SPOSite -Detailed | select Url, SensitivityLabel
WARNING: The -Detailed parameter will be deprecated for bulk enumeration.- Martin RublikFeb 11, 2021Brass Contributor
fhunth for what it's worth it seems that SensitivityLabel property is filled only if you use the -Identity $siteUrl filter. So you would need to iterate through all the sites and get the sites again :(.
So basically you need to iterate
$sites=Get-SPOSite -Limit ALL
$sites | ForEach-Object {
$site=Get-SPOSite -Identity $siteUrl
if ($site.SensitivityLabel -eq 'ID-HighlyCOnfidential')
{
return $site
}
}