Get-SPOSite how to get all sites on my tenant with a Sensitivity label = Highly Confidential?

Copper Contributor

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 with a sensitivy label?

5 Replies

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.

Same result. New Warning
PS C:\WINDOWS\system32> Get-SPOSite -Detailed | select Url, SensitivityLabel 
WARNING: The -Detailed parameter will be deprecated for bulk enumeration.

@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

}

}