I have a requirement to add sensitivity label to document libraries of multiple site collections.

I found below PnP PowerShell Command as per https://pnp.github.io/powershell/cmdlets/Set-PnPList.html

Set-PnPList -Identity "Demo List" -DefaultSensitivityLabelForLibrary "Confidential" -Connection $ModernSiteConnection

$ModernSiteConnection = Connection establish using certificate and working for other operations like applying sensitivity label to site collection.so no issue with connection

but the above command for applying sensitivity Label for Document library is not working saying A parameter cannot be found that matches parameter name 'DefaultSensitivityLabelForLibrary' even i can not see DefaultSensitivityLabelForLibrary in intelligence while other all parameter i can see and tried one of those like EnableContentTypes it worked.

I am using 2.2.1 version of pnp.powershell

can you please help me to understand what is the problem.

Trying to add sensitivity label to document library using pnp powershell Set-PnPList -Identity $LibraryName -DefaultSensitivityLabelForLibrary "Restricted" -Connection $ModernSiteConnection

but getting error A parameter cannot be found that matches parameter name 'DefaultSensitivityLabelForLibrary'

1

There are 1 answers

0
Ganesh Sanap - MVP On

I think there is some version conflict in the PnP PowerShell modules/versions installed on your system.

I think the current stable & latest of PnP PowerShell is v2.2.0.

And DefaultSensitivityLabelForLibrary parameter of Set-PnPList cmdlet was added to PnP PowerShell in v2.1.0.

Try below steps once:

  1. Uninstall all versions of SharePointPnPPowershellOnline module from your system.

  2. Uninstall all versions of PnP PowerShell modules from your system

  3. Install the latest and stable version (v2.2.0) of PnP PowerShell by following below documentations

Documentations:

  1. Upgrading from the Legacy version of PnP PowerShell
  2. Installing PnP PowerShell