Skip to content

[BUG] Get-PnPTenantSite Returns Empty SensitivityLabel and Get-PnPProperty Fails Due to ClientObject Type Mismatch #5075

@YuriySamorodov

Description

@YuriySamorodov

Reporting an Issue or Missing Feature

This is a bug report regarding the retrieval of SensitivityLabel values using Get-PnPTenantSite and the compatibility of objects with Get-PnPProperty. The SensitivityLabel information is not being populated as expected, and Get-PnPProperty fails to load the property from returned site objects.

Expected behavior

When running the following commands:

$sites = Get-PnPTenantSite
foreach ($site in $sites) {
    Get-PnPProperty -ClientObject $site -Property SensitivityLabel
}

or accessing:

$sites[100].SensitivityLabel

Expected result:
The SensitivityLabel property should return the sensitivity label assigned to each SharePoint site, as visible in the SharePoint Admin Center.
Get-PnPProperty should successfully populate/load the SensitivityLabel property for each site.

Actual behavior

  • The SensitivityLabel property on the objects returned by Get-PnPTenantSite (with or without -Detailed) is always empty, even though sites have labels assigned.
  • Attempting to use Get-PnPProperty -ClientObject $site -Property SensitivityLabel fails with this error:
    Get-PnPProperty: Cannot bind parameter 'ClientObject'. Cannot convert the "PnP.PowerShell.Commands.Model.SPOSite" value of type "PnP.PowerShell.Commands.Model.SPOSite" to type "Microsoft.SharePoint.Client.ClientObject".
    
  • This indicates an object type mismatch: the SPOSite object returned is not compatible with the required ClientObject parameter for Get-PnPProperty.

Screenshots

  • Attempting to use Get-PnPProperty produces the above error (see attached screenshot).
Image
  • Accessing $sites[100].SensitivityLabel always displays an empty value, even for labeled sites (see attached screenshot).
Image

Steps to reproduce behavior

  1. Use PnP PowerShell v3.1.141 to connect to SharePoint Online as a tenant administrator.

  2. Run:

    $sites = Get-PnPTenantSite -Detailed
    foreach ($site in $sites) {
        Get-PnPProperty -ClientObject $site -Property SensitivityLabel
    }

    OR

    $sites = Get-PnPTenantSite -Detailed
    $sites.SensitivityLabel
  3. Observe that the SensitivityLabel property is always empty, and that Get-PnPProperty fails due to a type incompatibility.

What is the version of the Cmdlet module you are running?

PnP.PowerShell v3.1.141

Which operating system/environment are you running PnP PowerShell on?

  • Windows
  • Linux
  • MacOS
  • Azure Cloud Shell
  • Azure Functions
  • Other : please specify

Related issue

#360
#2442

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions