Using PnP PowerShell Apply label to items in this list or library

Copper Contributor

Hi All,

 

I am trying below PowerShell code for applying the retail policy to "Apply label to items in this list or library" but getting some Waring as mentioned below.

 

This is the ("30 Years Delete (Delete after 30 years)") default Label available for all list and libraris.

 

Kindly let me know how to Apply label to items in this list or library using PnP PowerShell.

 

Code:

Connect-PnPOnline -Url $siteURL -UseWebLogin

Set-PnPLabel -List "Documents" -Label "30 Years Delete (Delete after 30 years)" -SyncToItems $true

 

WARNING: Can not find compliance tag with value: Default. SiteSubscriptionId: 38ae3bcd-9579-4fd4-adda-b42e1495d55a

 

 

11 Replies

Hi @harishpatil,

you are most probably getting the warning messagge because the Set-PnPLabel cmdlet is looking for a compliance tag with the value Default.
However, there is no compliance tag with that value.

To try to resolve this issue, you can use the following PowerShell script to apply the 30 Years Delete (Delete after 30 years) label to all items in the Documents library:

 

Connect-PnPOnline -Url $siteURL -UseWebLogin

# Get the compliance tag with the value "30 Years Delete (Delete after 30 years)"
$complianceTag = Get-PnPComplianceTag -Label "30 Years Delete (Delete after 30 years)"

# Apply the compliance tag to all items in the "Documents" library
Set-PnPLabel -List "Documents" -Label $complianceTag -SyncToItems $true

 

 

This script will first get the compliance tag with the value 30 Years Delete (Delete after 30 years). Then, it will apply the compliance tag to all items in the Documents library.

 

Please click Mark as Best Response & Like if my post helped you to solve your issue.
This will help others to find the correct solution easily. It also closes the item.


If the post was useful in other ways, please consider giving it Like.


Kindest regards,


Leon Pavesic

Hi Leaon,

Thank you very much for the quick response. I am getting below errors on specific line/command.

# Get the compliance tag with the value "30 Years Delete (Delete after 30 years)"
$complianceTag = Get-PnPComplianceTag -Label "30 Years Delete (Delete after 30 years)"

Get-PnPComplianceTag : The term 'Get-PnPComplianceTag' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path
was included, verify that the path is correct and try again.
At C:\OnlineMigration\Suresh\001-Comparison\Apply_Label_Retail_Policies.ps1:6 char:18
+ $complianceTag = Get-PnPComplianceTag -Label "30 Years Delete (Delete ...
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-PnPComplianceTag:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

And:

# Apply the compliance tag to all items in the "Documents" library
Set-PnPLabel -List "Documents" -Label $complianceTag -SyncToItems $true

Set-PnPLabel : Cannot bind argument to parameter 'Label' because it is null.
At C:\OnlineMigration\Suresh\001-Comparison\Apply_Label_Retail_Policies.ps1:9 char:39
+ Set-PnPLabel -List "Documents" -Label $complianceTag -SyncToItems $tr ...
+ ~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Set-PnPLabel], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,PnP.PowerShell.Commands.InformationManagement.SetLabel

Kindly help me how to get it resolve this issue.

Hi @harishpatil,

thanks for your Update.

To resolve the issue you are facing, you will need to install the PnP PowerShell cmdlets.

You can install the PnP PowerShell cmdlets using the following steps:

  1. Open a PowerShell console.
  2. Run the following command:

 

Install-Module -Name SharePointPnPPowerShellOnline -Force​

 

Once the PnP PowerShell cmdlets are installed, you should be able to run the PowerShell script without errors.

 

Connect-PnPOnline -Url $siteURL -UseWebLogin

# Get the compliance tag with the value "30 Years Delete (Delete after 30 years)"
$complianceTag = Get-PnPComplianceTag -Label "30 Years Delete (Delete after 30 years)"

# Apply the compliance tag to all items in the "Documents" library
Set-PnPLabel -List "Documents" -Label $complianceTag -SyncToItems $true

 

 

Please also restart PowerShell after installing the PnP PowerShell cmdlets in order for the changes to take effect.

Please click Mark as Best Response & Like if my post helped you to solve your issue.
This will help others to find the correct solution easily. It also closes the item.


If the post was useful in other ways, please consider giving it Like.


Kindest regards,


Leon Pavesic

Hi Leon,

I tried to install that module but getting below error. Kindly help me to how resolve the same.
Install-Module -Name SharePointPnPPowerShellOnline -Force​

Errors:

PackageManagement\Install-Package : The following commands are already available on this system:'Ensure-PnPFolder,Execute-PnPQuery,Export-PnPClientSidePage,Export-PnPClientSidePageMapping,Ge
t-PnPAvailableClientSideComponents,Get-PnPClientSideComponent,Get-PnPClientSidePage,Get-PnPMicrosoft365GroupMembers,Get-PnPMicrosoft365GroupOwners,Invoke-PnPSearchQuery,Load-PnPProvisioningT
emplate,Move-PnPClientSideComponent,Remove-PnPClientSideComponent,Remove-PnPClientSidePage,Save-PnPClientSidePageConversionLog,Set-PnPClientSidePage,Set-PnPClientSideText,Set-PnPClientSideWe
bPart,Add-PnPAlert,Add-PnPApp,Add-PnPApplicationCustomizer,Add-PnPClientSidePageSection,Add-PnPClientSideText,Add-PnPClientSideWebPart,Add-PnPContentType,Add-PnPContentTypeToDocumentSet,Add-
PnPContentTypeToList,Add-PnPCustomAction,Add-PnPDataRowsToProvisioningTemplate,Add-PnPDocumentSet,Add-PnPEventReceiver,Add-PnPField,Add-PnPFieldFromXml,Add-PnPFieldToContentType,Add-PnPFile,
Add-PnPFileToProvisioningTemplate,Add-PnPFolder,Add-PnPHtmlPublishingPageLayout,Add-PnPHubSiteAssociation,Add-PnPIndexedProperty,Add-PnPJavaScriptBlock,Add-PnPJavaScriptLink,Add-PnPListFolde
rsToProvisioningTemplate,Add-PnPListItem,Add-PnPMasterPage,Add-PnPMicrosoft365GroupMember,Add-PnPMicrosoft365GroupOwner,Add-PnPMicrosoft365GroupToSite,Add-PnPNavigationNode,Add-PnPOrgAssetsL
ibrary,Add-PnPOrgNewsSite,Add-PnPPublishingImageRendition,Add-PnPPublishingPage,Add-PnPPublishingPageLayout,Add-PnPRoleDefinition,Add-PnPSiteClassification,Add-PnPSiteCollectionAdmin,Add-PnP
SiteCollectionAppCatalog,Add-PnPSiteDesign,Add-PnPSiteDesignTask,Add-PnPSiteScript,Add-PnPStoredCredential,Add-PnPTaxonomyField,Add-PnPTeamsChannel,Add-PnPTeamsTab,Add-PnPTeamsTeam,Add-PnPTe
amsUser,Add-PnPTenantCdnOrigin,Add-PnPTenantSequence,Add-PnPTenantSequenceSite,Add-PnPTenantSequenceSubSite,Add-PnPTenantTheme,Add-PnPUserToGroup,Add-PnPView,Add-PnPWebhookSubscription,Add-P
nPWebPartToWebPartPage,Add-PnPWebPartToWikiPage,Add-PnPWikiPage,Add-PnPWorkflowDefinition,Add-PnPWorkflowSubscription,Apply-PnPProvisioningTemplate,Approve-PnPTenantServicePrincipalPermissio
nRequest,Clear-PnPDefaultColumnValues,Clear-PnPListItemAsRecord,Clear-PnPMicrosoft365GroupMember,Clear-PnPMicrosoft365GroupOwner,Clear-PnPRecycleBinItem,Clear-PnPTenantAppCatalogUrl,Clear-Pn
PTenantRecycleBinItem,Connect-PnPOnline,Convert-PnPFolderToProvisioningTemplate,Convert-PnPProvisioningTemplate,Copy-PnPFile,Copy-PnPItemProxy,Deny-PnPTenantServicePrincipalPermissionRequest
,Disable-PnPFeature,Disable-PnPInPlaceRecordsManagementForSite,Disable-PnPPowerShellTelemetry,Disable-PnPResponsiveUI,Disable-PnPSharingForNonOwnersOfSite,Disable-PnPSiteClassification,Disab
le-PnPTenantServicePrincipal,Disconnect-PnPOnline,Enable-PnPCommSite,Enable-PnPFeature,Enable-PnPInPlaceRecordsManagementForSite,Enable-PnPPowerShellTelemetry,Enable-PnPResponsiveUI,Enable-P
nPSiteClassification,Enable-PnPTenantServicePrincipal,Export-PnPListToProvisioningTemplate,Export-PnPTaxonomy,Export-PnPTermGroupToXml,Find-PnPFile,Get-PnPAADUser,Get-PnPAccessToken,Get-PnPA
lert,Get-PnPApp,Get-PnPAppAuthAccessToken,Get-PnPAppInstance,Get-PnPApplicationCustomizer,Get-PnPAuditing,Get-PnPAuthenticationRealm,Get-PnPAvailableLanguage,Get-PnPAzureCertificate,Get-PnPC
onnection,Get-PnPContentType,Get-PnPContentTypePublishingHubUrl,Get-PnPContext,Get-PnPCustomAction,Get-PnPDefaultColumnValues,Get-PnPDeletedMicrosoft365Group,Get-PnPDocumentSetTemplate,Get-P
nPEventReceiver,Get-PnPException,Get-PnPFeature,Get-PnPField,Get-PnPFile,Get-PnPFileVersion,Get-PnPFolder,Get-PnPFolderItem,Get-PnPFooter,Get-PnPGraphAccessToken,Get-PnPGraphSubscription,Get
-PnPGroup,Get-PnPGroupMembers,Get-PnPGroupPermissions,Get-PnPHealthScore,Get-PnPHideDefaultThemes,Get-PnPHomePage,Get-PnPHomeSite,Get-PnPHubSite,Get-PnPHubSiteChild,Get-PnPIndexedPropertyKey
s,Get-PnPInPlaceRecordsManagement,Get-PnPIsSiteAliasAvailable,Get-PnPJavaScriptLink,Get-PnPKnowledgeHubSite,Get-PnPLabel,Get-PnPList,Get-PnPListInformationRightsManagement,Get-PnPListItem,Ge
t-PnPListRecordDeclaration,Get-PnPMasterPage,Get-PnPMicrosoft365Group,Get-PnPNavigationNode,Get-PnPOffice365CurrentServiceStatus,Get-PnPOffice365HistoricalServiceStatus,Get-PnPOffice365Servi
ceMessage,Get-PnPOffice365Services,Get-PnPOrgAssetsLibrary,Get-PnPOrgNewsSite,Get-PnPPowerShellTelemetryEnabled,Get-PnPProperty,Get-PnPPropertyBag,Get-PnPProvisioningTemplate,Get-PnPPublishi
ngImageRendition,Get-PnPRecycleBinItem,Get-PnPRequestAccessEmails,Get-PnPRoleDefinition,Get-PnPSearchConfiguration,Get-PnPSearchCrawlLog,Get-PnPSearchSettings,Get-PnPSharingForNonOwnersOfSit
e,Get-PnPSite,Get-PnPSiteClassification,Get-PnPSiteClosure,Get-PnPSiteCollectionAdmin,Get-PnPSiteCollectionTermStore,Get-PnPSiteDesign,Get-PnPSiteDesignRights,Get-PnPSiteDesignRun,Get-PnPSit
eDesignRunStatus,Get-PnPSiteDesignTask,Get-PnPSitePolicy,Get-PnPSiteScript,Get-PnPSiteScriptFromList,Get-PnPSiteScriptFromWeb,Get-PnPSiteSearchQueryResults,Get-PnPStorageEntity,Get-PnPStored
Credential,Get-PnPSubWebs,Get-PnPTaxonomyItem,Get-PnPTaxonomySession,Get-PnPTeamsApp,Get-PnPTeamsChannel,Get-PnPTeamsChannelMessage,Get-PnPTeamsTab,Get-PnPTeamsTeam,Get-PnPTeamsUser,Get-PnPT
enant,Get-PnPTenantAppCatalogUrl,Get-PnPTenantCdnEnabled,Get-PnPTenantCdnOrigin,Get-PnPTenantCdnPolicies,Get-PnPTenantId,Get-PnPTenantRecycleBinItem,Get-PnPTenantSequence,Get-PnPTenantSequen
ceSite,Get-PnPTenantServicePrincipal,Get-PnPTenantServicePrincipalPermissionGrants,Get-PnPTenantServicePrincipalPermissionRequests,Get-PnPTenantSite,Get-PnPTenantSyncClientRestriction,Get-Pn
PTenantTemplate,Get-PnPTenantTheme,Get-PnPTerm,Get-PnPTermGroup,Get-PnPTermSet,Get-PnPTheme,Get-PnPTimeZoneId,Get-PnPUnifiedAuditLog,Get-PnPUPABulkImportStatus,Get-PnPUser,Get-PnPUserOneDriv
eQuota,Get-PnPUserProfileProperty,Get-PnPView,Get-PnPWeb,Get-PnPWebhookSubscriptions,Get-PnPWebPart,Get-PnPWebPartProperty,Get-PnPWebPartXml,Get-PnPWebTemplates,Get-PnPWikiPageContent,Get-Pn
PWorkflowDefinition,Get-PnPWorkflowInstance,Get-PnPWorkflowSubscription,Grant-PnPHubSiteRights,Grant-PnPSiteDesignRights,Grant-PnPTenantServicePrincipalPermission,Import-PnPAppPackage,Import
-PnPTaxonomy,Import-PnPTermGroupFromXml,Import-PnPTermSet,Install-PnPApp,Install-PnPSolution,Invoke-PnPQuery,Invoke-PnPSiteDesign,Invoke-PnPSPRestMethod,Invoke-PnPWebAction,Measure-PnPList,M
easure-PnPResponseTime,Measure-PnPWeb,Move-PnPFile,Move-PnPFolder,Move-PnPItemProxy,Move-PnPListItemToRecycleBin,Move-PnPRecycleBinItem,New-PnPAzureCertificate,New-PnPExtensibilityHandlerObj
ect,New-PnPGraphSubscription,New-PnPGroup,New-PnPList,New-PnPMicrosoft365Group,New-PnPPersonalSite,New-PnPProvisioningTemplate,New-PnPProvisioningTemplateFromFolder,New-PnPSite,New-PnPTeamsA
pp,New-PnPTeamsTeam,New-PnPTenantSequence,New-PnPTenantSequenceCommunicationSite,New-PnPTenantSequenceTeamNoGroupSite,New-PnPTenantSequenceTeamNoGroupSubSite,New-PnPTenantSequenceTeamSite,Ne
w-PnPTenantSite,New-PnPTenantTemplate,New-PnPTerm,New-PnPTermGroup,New-PnPTermLabel,New-PnPTermSet,New-PnPUPABulkImportJob,New-PnPUser,New-PnPWeb,Publish-PnPApp,Read-PnPProvisioningTemplate,
Read-PnPTenantTemplate,Register-PnPAppCatalogSite,Register-PnPHubSite,Register-PnPManagementShellAccess,Remove-PnPAlert,Remove-PnPApp,Remove-PnPApplicationCustomizer,Remove-PnPContentType,Re
move-PnPContentTypeFromDocumentSet,Remove-PnPContentTypeFromList,Remove-PnPCustomAction,Remove-PnPDeletedMicrosoft365Group,Remove-PnPEventReceiver,Remove-PnPField,Remove-PnPFieldFromContentT
ype,Remove-PnPFile,Remove-PnPFileFromProvisioningTemplate,Remove-PnPFileVersion,Remove-PnPFolder,Remove-PnPGraphSubscription,Remove-PnPGroup,Remove-PnPHomeSite,Remove-PnPHubSiteAssociation,R
emove-PnPIndexedProperty,Remove-PnPJavaScriptLink,Remove-PnPKnowledgeHubSite,Remove-PnPList,Remove-PnPListItem,Remove-PnPMicrosoft365Group,Remove-PnPMicrosoft365GroupMember,Remove-PnPMicroso
ft365GroupOwner,Remove-PnPNavigationNode,Remove-PnPOrgAssetsLibrary,Remove-PnPOrgNewsSite,Remove-PnPPropertyBagValue,Remove-PnPPublishingImageRendition,Remove-PnPRoleDefinition,Remove-PnPSea
rchConfiguration,Remove-PnPSiteClassification,Remove-PnPSiteCollectionAdmin,Remove-PnPSiteCollectionAppCatalog,Remove-PnPSiteDesign,Remove-PnPSiteDesignTask,Remove-PnPSiteScript,Remove-PnPSt
orageEntity,Remove-PnPStoredCredential,Remove-PnPTaxonomyItem,Remove-PnPTeamsApp,Remove-PnPTeamsChannel,Remove-PnPTeamsTab,Remove-PnPTeamsTeam,Remove-PnPTeamsUser,Remove-PnPTenantCdnOrigin,R
emove-PnPTenantSite,Remove-PnPTenantTheme,Remove-PnPTermGroup,Remove-PnPUser,Remove-PnPUserFromGroup,Remove-PnPView,Remove-PnPWeb,Remove-PnPWebhookSubscription,Remove-PnPWebPart,Remove-PnPWi
kiPage,Remove-PnPWorkflowDefinition,Remove-PnPWorkflowSubscription,Rename-PnPFile,Rename-PnPFolder,Request-PnPAccessToken,Request-PnPReIndexList,Request-PnPReIndexWeb,Reset-PnPFileVersion,Re
set-PnPLabel,Reset-PnPMicrosoft365GroupExpiration,Reset-PnPUserOneDriveQuotaToDefault,Resolve-PnPFolder,Restore-PnPDeletedMicrosoft365Group,Restore-PnPFileVersion,Restore-PnPRecycleBinItem,R
estore-PnPTenantRecycleBinItem,Resume-PnPWorkflowInstance,Revoke-PnPHubSiteRights,Revoke-PnPSiteDesignRights,Revoke-PnPTenantServicePrincipalPermission,Save-PnPProvisioningTemplate,Save-PnPT
enantTemplate,Send-PnPMail,Set-PnPApplicationCustomizer,Set-PnPAppSideLoading,Set-PnPAuditing,Set-PnPAvailablePageLayouts,Set-PnPContext,Set-PnPDefaultColumnValues,Set-PnPDefaultContentTypeT
oList,Set-PnPDefaultPageLayout,Set-PnPDocumentSetField,Set-PnPField,Set-PnPFileCheckedIn,Set-PnPFileCheckedOut,Set-PnPFolderPermission,Set-PnPFooter,Set-PnPGraphSubscription,Set-PnPGroup,Set
-PnPGroupPermissions,Set-PnPHideDefaultThemes,Set-PnPHomePage,Set-PnPHomeSite,Set-PnPHubSite,Set-PnPIndexedProperties,Set-PnPInPlaceRecordsManagement,Set-PnPKnowledgeHubSite,Set-PnPLabel,Set
-PnPList,Set-PnPListInformationRightsManagement,Set-PnPListItem,Set-PnPListItemAsRecord,Set-PnPListItemPermission,Set-PnPListPermission,Set-PnPListRecordDeclaration,Set-PnPMasterPage,Set-PnP
Microsoft365Group,Set-PnPMinimalDownloadStrategy,Set-PnPPropertyBagValue,Set-PnPProvisioningTemplateMetadata,Set-PnPRequestAccessEmails,Set-PnPSearchConfiguration,Set-PnPSearchSettings,Set-P
nPSite,Set-PnPSiteClosure,Set-PnPSiteDesign,Set-PnPSitePolicy,Set-PnPSiteScript,Set-PnPStorageEntity,Set-PnPTaxonomyFieldValue,Set-PnPTeamifyPromptHidden,Set-PnPTeamsChannel,Set-PnPTeamsTab,
Set-PnPTeamsTeam,Set-PnPTeamsTeamArchivedState,Set-PnPTeamsTeamPicture,Set-PnPTenant,Set-PnPTenantAppCatalogUrl,Set-PnPTenantCdnEnabled,Set-PnPTenantCdnPolicy,Set-PnPTenantSite,Set-PnPTenant
SyncClientRestriction,Set-PnPTermGroup,Set-PnPTermSet,Set-PnPTheme,Set-PnPTraceLog,Set-PnPUserOneDriveQuota,Set-PnPUserProfileProperty,Set-PnPView,Set-PnPWeb,Set-PnPWebhookSubscription,Set-P
nPWebPartProperty,Set-PnPWebPermission,Set-PnPWebTheme,Set-PnPWikiPageContent,Start-PnPWorkflowInstance,Stop-PnPWorkflowInstance,Submit-PnPSearchQuery,Submit-PnPTeamsChannelMessage,Sync-PnPA
ppToTeams,Test-PnPListItemIsRecord,Test-PnPTenantTemplate,Uninstall-PnPApp,Uninstall-PnPAppInstance,Uninstall-PnPSolution,Unpublish-PnPApp,Unregister-PnPHubSite,Update-PnPApp,Update-PnPSiteC
lassification,Update-PnPTeamsApp'. This module 'SharePointPnPPowerShellOnline' may override the existing commands. If you still want to install this module 'SharePointPnPPowerShellOnline',
use -AllowClobber parameter.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.2.5\PSModule.psm1:9711 char:34
+ ... talledPackages = PackageManagement\Install-Package @PSBoundParameters
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception
+ FullyQualifiedErrorId : CommandAlreadyAvailable,Validate-ModuleCommandAlreadyAvailable,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

@LeonPavesic 

 

Hi Leon,

 

I tried to install that module but getting below error. Kindly help me how to resolve the same.


Install-Module -Name SharePointPnPPowerShellOnline -Force​

 

Errors:

PackageManagement\Install-Package : The following commands are already available on this system:'Ensure-PnPFolder,Execute-PnPQuery,Export-PnPClientSidePage,Export-PnPClientSidePageMapping,Ge
t-PnPAvailableClientSideComponents,Get-PnPClientSideComponent,Get-PnPClientSidePage,Get-PnPMicrosoft365GroupMembers,Get-PnPMicrosoft365GroupOwners,Invoke-PnPSearchQuery,Load-PnPProvisioningT
emplate,Move-PnPClientSideComponent,Remove-PnPClientSideComponent,Remove-PnPClientSidePage,Save-PnPClientSidePageConversionLog,Set-PnPClientSidePage,Set-PnPClientSideText,Set-PnPClientSideWe
bPart,Add-PnPAlert,Add-PnPApp,Add-PnPApplicationCustomizer,Add-PnPClientSidePageSection,Add-PnPClientSideText,Add-PnPClientSideWebPart,Add-PnPContentType,Add-PnPContentTypeToDocumentSet,Add-
PnPContentTypeToList,Add-PnPCustomAction,Add-PnPDataRowsToProvisioningTemplate,Add-PnPDocumentSet,Add-PnPEventReceiver,Add-PnPField,Add-PnPFieldFromXml,Add-PnPFieldToContentType,Add-PnPFile,
Add-PnPFileToProvisioningTemplate,Add-PnPFolder,Add-PnPHtmlPublishingPageLayout,Add-PnPHubSiteAssociation,Add-PnPIndexedProperty,Add-PnPJavaScriptBlock,Add-PnPJavaScriptLink,Add-PnPListFolde
rsToProvisioningTemplate,Add-PnPListItem,Add-PnPMasterPage,Add-PnPMicrosoft365GroupMember,Add-PnPMicrosoft365GroupOwner,Add-PnPMicrosoft365GroupToSite,Add-PnPNavigationNode,Add-PnPOrgAssetsL
ibrary,Add-PnPOrgNewsSite,Add-PnPPublishingImageRendition,Add-PnPPublishingPage,Add-PnPPublishingPageLayout,Add-PnPRoleDefinition,Add-PnPSiteClassification,Add-PnPSiteCollectionAdmin,Add-PnP
SiteCollectionAppCatalog,Add-PnPSiteDesign,Add-PnPSiteDesignTask,Add-PnPSiteScript,Add-PnPStoredCredential,Add-PnPTaxonomyField,Add-PnPTeamsChannel,Add-PnPTeamsTab,Add-PnPTeamsTeam,Add-PnPTe
amsUser,Add-PnPTenantCdnOrigin,Add-PnPTenantSequence,Add-PnPTenantSequenceSite,Add-PnPTenantSequenceSubSite,Add-PnPTenantTheme,Add-PnPUserToGroup,Add-PnPView,Add-PnPWebhookSubscription,Add-P
nPWebPartToWebPartPage,Add-PnPWebPartToWikiPage,Add-PnPWikiPage,Add-PnPWorkflowDefinition,Add-PnPWorkflowSubscription,Apply-PnPProvisioningTemplate,Approve-PnPTenantServicePrincipalPermissio
nRequest,Clear-PnPDefaultColumnValues,Clear-PnPListItemAsRecord,Clear-PnPMicrosoft365GroupMember,Clear-PnPMicrosoft365GroupOwner,Clear-PnPRecycleBinItem,Clear-PnPTenantAppCatalogUrl,Clear-Pn
PTenantRecycleBinItem,Connect-PnPOnline,Convert-PnPFolderToProvisioningTemplate,Convert-PnPProvisioningTemplate,Copy-PnPFile,Copy-PnPItemProxy,Deny-PnPTenantServicePrincipalPermissionRequest
,Disable-PnPFeature,Disable-PnPInPlaceRecordsManagementForSite,Disable-PnPPowerShellTelemetry,Disable-PnPResponsiveUI,Disable-PnPSharingForNonOwnersOfSite,Disable-PnPSiteClassification,Disab
le-PnPTenantServicePrincipal,Disconnect-PnPOnline,Enable-PnPCommSite,Enable-PnPFeature,Enable-PnPInPlaceRecordsManagementForSite,Enable-PnPPowerShellTelemetry,Enable-PnPResponsiveUI,Enable-P
nPSiteClassification,Enable-PnPTenantServicePrincipal,Export-PnPListToProvisioningTemplate,Export-PnPTaxonomy,Export-PnPTermGroupToXml,Find-PnPFile,Get-PnPAADUser,Get-PnPAccessToken,Get-PnPA
lert,Get-PnPApp,Get-PnPAppAuthAccessToken,Get-PnPAppInstance,Get-PnPApplicationCustomizer,Get-PnPAuditing,Get-PnPAuthenticationRealm,Get-PnPAvailableLanguage,Get-PnPAzureCertificate,Get-PnPC
onnection,Get-PnPContentType,Get-PnPContentTypePublishingHubUrl,Get-PnPContext,Get-PnPCustomAction,Get-PnPDefaultColumnValues,Get-PnPDeletedMicrosoft365Group,Get-PnPDocumentSetTemplate,Get-P
nPEventReceiver,Get-PnPException,Get-PnPFeature,Get-PnPField,Get-PnPFile,Get-PnPFileVersion,Get-PnPFolder,Get-PnPFolderItem,Get-PnPFooter,Get-PnPGraphAccessToken,Get-PnPGraphSubscription,Get
-PnPGroup,Get-PnPGroupMembers,Get-PnPGroupPermissions,Get-PnPHealthScore,Get-PnPHideDefaultThemes,Get-PnPHomePage,Get-PnPHomeSite,Get-PnPHubSite,Get-PnPHubSiteChild,Get-PnPIndexedPropertyKey
s,Get-PnPInPlaceRecordsManagement,Get-PnPIsSiteAliasAvailable,Get-PnPJavaScriptLink,Get-PnPKnowledgeHubSite,Get-PnPLabel,Get-PnPList,Get-PnPListInformationRightsManagement,Get-PnPListItem,Ge
t-PnPListRecordDeclaration,Get-PnPMasterPage,Get-PnPMicrosoft365Group,Get-PnPNavigationNode,Get-PnPOffice365CurrentServiceStatus,Get-PnPOffice365HistoricalServiceStatus,Get-PnPOffice365Servi
ceMessage,Get-PnPOffice365Services,Get-PnPOrgAssetsLibrary,Get-PnPOrgNewsSite,Get-PnPPowerShellTelemetryEnabled,Get-PnPProperty,Get-PnPPropertyBag,Get-PnPProvisioningTemplate,Get-PnPPublishi
ngImageRendition,Get-PnPRecycleBinItem,Get-PnPRequestAccessEmails,Get-PnPRoleDefinition,Get-PnPSearchConfiguration,Get-PnPSearchCrawlLog,Get-PnPSearchSettings,Get-PnPSharingForNonOwnersOfSit
e,Get-PnPSite,Get-PnPSiteClassification,Get-PnPSiteClosure,Get-PnPSiteCollectionAdmin,Get-PnPSiteCollectionTermStore,Get-PnPSiteDesign,Get-PnPSiteDesignRights,Get-PnPSiteDesignRun,Get-PnPSit
eDesignRunStatus,Get-PnPSiteDesignTask,Get-PnPSitePolicy,Get-PnPSiteScript,Get-PnPSiteScriptFromList,Get-PnPSiteScriptFromWeb,Get-PnPSiteSearchQueryResults,Get-PnPStorageEntity,Get-PnPStored
Credential,Get-PnPSubWebs,Get-PnPTaxonomyItem,Get-PnPTaxonomySession,Get-PnPTeamsApp,Get-PnPTeamsChannel,Get-PnPTeamsChannelMessage,Get-PnPTeamsTab,Get-PnPTeamsTeam,Get-PnPTeamsUser,Get-PnPT
enant,Get-PnPTenantAppCatalogUrl,Get-PnPTenantCdnEnabled,Get-PnPTenantCdnOrigin,Get-PnPTenantCdnPolicies,Get-PnPTenantId,Get-PnPTenantRecycleBinItem,Get-PnPTenantSequence,Get-PnPTenantSequen
ceSite,Get-PnPTenantServicePrincipal,Get-PnPTenantServicePrincipalPermissionGrants,Get-PnPTenantServicePrincipalPermissionRequests,Get-PnPTenantSite,Get-PnPTenantSyncClientRestriction,Get-Pn
PTenantTemplate,Get-PnPTenantTheme,Get-PnPTerm,Get-PnPTermGroup,Get-PnPTermSet,Get-PnPTheme,Get-PnPTimeZoneId,Get-PnPUnifiedAuditLog,Get-PnPUPABulkImportStatus,Get-PnPUser,Get-PnPUserOneDriv
eQuota,Get-PnPUserProfileProperty,Get-PnPView,Get-PnPWeb,Get-PnPWebhookSubscriptions,Get-PnPWebPart,Get-PnPWebPartProperty,Get-PnPWebPartXml,Get-PnPWebTemplates,Get-PnPWikiPageContent,Get-Pn
PWorkflowDefinition,Get-PnPWorkflowInstance,Get-PnPWorkflowSubscription,Grant-PnPHubSiteRights,Grant-PnPSiteDesignRights,Grant-PnPTenantServicePrincipalPermission,Import-PnPAppPackage,Import
-PnPTaxonomy,Import-PnPTermGroupFromXml,Import-PnPTermSet,Install-PnPApp,Install-PnPSolution,Invoke-PnPQuery,Invoke-PnPSiteDesign,Invoke-PnPSPRestMethod,Invoke-PnPWebAction,Measure-PnPList,M
easure-PnPResponseTime,Measure-PnPWeb,Move-PnPFile,Move-PnPFolder,Move-PnPItemProxy,Move-PnPListItemToRecycleBin,Move-PnPRecycleBinItem,New-PnPAzureCertificate,New-PnPExtensibilityHandlerObj
ect,New-PnPGraphSubscription,New-PnPGroup,New-PnPList,New-PnPMicrosoft365Group,New-PnPPersonalSite,New-PnPProvisioningTemplate,New-PnPProvisioningTemplateFromFolder,New-PnPSite,New-PnPTeamsA
pp,New-PnPTeamsTeam,New-PnPTenantSequence,New-PnPTenantSequenceCommunicationSite,New-PnPTenantSequenceTeamNoGroupSite,New-PnPTenantSequenceTeamNoGroupSubSite,New-PnPTenantSequenceTeamSite,Ne
w-PnPTenantSite,New-PnPTenantTemplate,New-PnPTerm,New-PnPTermGroup,New-PnPTermLabel,New-PnPTermSet,New-PnPUPABulkImportJob,New-PnPUser,New-PnPWeb,Publish-PnPApp,Read-PnPProvisioningTemplate,
Read-PnPTenantTemplate,Register-PnPAppCatalogSite,Register-PnPHubSite,Register-PnPManagementShellAccess,Remove-PnPAlert,Remove-PnPApp,Remove-PnPApplicationCustomizer,Remove-PnPContentType,Re
move-PnPContentTypeFromDocumentSet,Remove-PnPContentTypeFromList,Remove-PnPCustomAction,Remove-PnPDeletedMicrosoft365Group,Remove-PnPEventReceiver,Remove-PnPField,Remove-PnPFieldFromContentT
ype,Remove-PnPFile,Remove-PnPFileFromProvisioningTemplate,Remove-PnPFileVersion,Remove-PnPFolder,Remove-PnPGraphSubscription,Remove-PnPGroup,Remove-PnPHomeSite,Remove-PnPHubSiteAssociation,R
emove-PnPIndexedProperty,Remove-PnPJavaScriptLink,Remove-PnPKnowledgeHubSite,Remove-PnPList,Remove-PnPListItem,Remove-PnPMicrosoft365Group,Remove-PnPMicrosoft365GroupMember,Remove-PnPMicroso
ft365GroupOwner,Remove-PnPNavigationNode,Remove-PnPOrgAssetsLibrary,Remove-PnPOrgNewsSite,Remove-PnPPropertyBagValue,Remove-PnPPublishingImageRendition,Remove-PnPRoleDefinition,Remove-PnPSea
rchConfiguration,Remove-PnPSiteClassification,Remove-PnPSiteCollectionAdmin,Remove-PnPSiteCollectionAppCatalog,Remove-PnPSiteDesign,Remove-PnPSiteDesignTask,Remove-PnPSiteScript,Remove-PnPSt
orageEntity,Remove-PnPStoredCredential,Remove-PnPTaxonomyItem,Remove-PnPTeamsApp,Remove-PnPTeamsChannel,Remove-PnPTeamsTab,Remove-PnPTeamsTeam,Remove-PnPTeamsUser,Remove-PnPTenantCdnOrigin,R
emove-PnPTenantSite,Remove-PnPTenantTheme,Remove-PnPTermGroup,Remove-PnPUser,Remove-PnPUserFromGroup,Remove-PnPView,Remove-PnPWeb,Remove-PnPWebhookSubscription,Remove-PnPWebPart,Remove-PnPWi
kiPage,Remove-PnPWorkflowDefinition,Remove-PnPWorkflowSubscription,Rename-PnPFile,Rename-PnPFolder,Request-PnPAccessToken,Request-PnPReIndexList,Request-PnPReIndexWeb,Reset-PnPFileVersion,Re
set-PnPLabel,Reset-PnPMicrosoft365GroupExpiration,Reset-PnPUserOneDriveQuotaToDefault,Resolve-PnPFolder,Restore-PnPDeletedMicrosoft365Group,Restore-PnPFileVersion,Restore-PnPRecycleBinItem,R
estore-PnPTenantRecycleBinItem,Resume-PnPWorkflowInstance,Revoke-PnPHubSiteRights,Revoke-PnPSiteDesignRights,Revoke-PnPTenantServicePrincipalPermission,Save-PnPProvisioningTemplate,Save-PnPT
enantTemplate,Send-PnPMail,Set-PnPApplicationCustomizer,Set-PnPAppSideLoading,Set-PnPAuditing,Set-PnPAvailablePageLayouts,Set-PnPContext,Set-PnPDefaultColumnValues,Set-PnPDefaultContentTypeT
oList,Set-PnPDefaultPageLayout,Set-PnPDocumentSetField,Set-PnPField,Set-PnPFileCheckedIn,Set-PnPFileCheckedOut,Set-PnPFolderPermission,Set-PnPFooter,Set-PnPGraphSubscription,Set-PnPGroup,Set
-PnPGroupPermissions,Set-PnPHideDefaultThemes,Set-PnPHomePage,Set-PnPHomeSite,Set-PnPHubSite,Set-PnPIndexedProperties,Set-PnPInPlaceRecordsManagement,Set-PnPKnowledgeHubSite,Set-PnPLabel,Set
-PnPList,Set-PnPListInformationRightsManagement,Set-PnPListItem,Set-PnPListItemAsRecord,Set-PnPListItemPermission,Set-PnPListPermission,Set-PnPListRecordDeclaration,Set-PnPMasterPage,Set-PnP
Microsoft365Group,Set-PnPMinimalDownloadStrategy,Set-PnPPropertyBagValue,Set-PnPProvisioningTemplateMetadata,Set-PnPRequestAccessEmails,Set-PnPSearchConfiguration,Set-PnPSearchSettings,Set-P
nPSite,Set-PnPSiteClosure,Set-PnPSiteDesign,Set-PnPSitePolicy,Set-PnPSiteScript,Set-PnPStorageEntity,Set-PnPTaxonomyFieldValue,Set-PnPTeamifyPromptHidden,Set-PnPTeamsChannel,Set-PnPTeamsTab,
Set-PnPTeamsTeam,Set-PnPTeamsTeamArchivedState,Set-PnPTeamsTeamPicture,Set-PnPTenant,Set-PnPTenantAppCatalogUrl,Set-PnPTenantCdnEnabled,Set-PnPTenantCdnPolicy,Set-PnPTenantSite,Set-PnPTenant
SyncClientRestriction,Set-PnPTermGroup,Set-PnPTermSet,Set-PnPTheme,Set-PnPTraceLog,Set-PnPUserOneDriveQuota,Set-PnPUserProfileProperty,Set-PnPView,Set-PnPWeb,Set-PnPWebhookSubscription,Set-P
nPWebPartProperty,Set-PnPWebPermission,Set-PnPWebTheme,Set-PnPWikiPageContent,Start-PnPWorkflowInstance,Stop-PnPWorkflowInstance,Submit-PnPSearchQuery,Submit-PnPTeamsChannelMessage,Sync-PnPA
ppToTeams,Test-PnPListItemIsRecord,Test-PnPTenantTemplate,Uninstall-PnPApp,Uninstall-PnPAppInstance,Uninstall-PnPSolution,Unpublish-PnPApp,Unregister-PnPHubSite,Update-PnPApp,Update-PnPSiteC
lassification,Update-PnPTeamsApp'. This module 'SharePointPnPPowerShellOnline' may override the existing commands. If you still want to install this module 'SharePointPnPPowerShellOnline',
use -AllowClobber parameter.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.2.5\PSModule.psm1:9711 char:34
+ ... talledPackages = PackageManagement\Install-Package @PSBoundParameters
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception
+ FullyQualifiedErrorId : CommandAlreadyAvailable,Validate-ModuleCommandAlreadyAvailable,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

Hi @harishpatil,

 

It appears that some of the commands in this module might already exist in your PowerShell environment, causing a conflict.

To resolve this, you can try installing the module with the -AllowClobber parameter. This parameter allows the module to override existing commands with the same names, potentially resolving conflicts. Here's how you can do it:

 

 

 

Install-Module -Name SharePointPnPPowerShellOnline -Force -AllowClobber



 

Adding the -AllowClobber parameter should help you install the module without conflicts. After that, you can proceed with the rest of the PowerShell script as previously provided.

Please click Mark as Best Response & Like if my post helped you to solve your issue.
This will help others to find the correct solution easily. It also closes the item.


If the post was useful in other ways, please consider giving it Like.


Kindest regards,


Leon Pavesic

Hi Leon,

I have installed the mentioned module without any errors. It was showing installing Complete and it cam back on command prompt. Again I tried to run our script but still getting same below error.
Do I need to install any other things?

Error:

Get-PnPComplianceTag : The term 'Get-PnPComplianceTag' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path
was included, verify that the path is correct and try again.
At C:\OnlineMigration\Suresh\001-Comparison\Apply_Label_Retain_Policies.ps1:6 char:18
+ $complianceTag = Get-PnPComplianceTag -Label "30 Years Delete (Delete ...
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-PnPComplianceTag:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

Set-PnPLabel : Cannot bind argument to parameter 'Label' because it is null.
At C:\OnlineMigration\Suresh\001-Comparison\Apply_Label_Retain_Policies.ps1:9 char:39
+ Set-PnPLabel -List "Documents" -Label $complianceTag -SyncToItems $tr ...
+ ~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Set-PnPLabel], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,PnP.PowerShell.Commands.InformationManagement.SetLabel

Hi Leon,

I have check on Google also regarding tag Get-PnPComplianceTag but not able to find anything regarding the same.

Also in PowerShell also not able to get that tag. Is this related with PnP PowerShell?

Which version I need to use for the same for PnP PowerShell? I have installed below version on my machine.


PS C:\Users\z003ve3v> Get-Module SharePointPnPPowerShell* -ListAvailable | Select-Object Name,Version | Sort-Object Version -Descending

Name Version
---- -------
SharePointPnPPowerShellOnline 3.29.2101.0
SharePointPnPPowerShell2013 3.29.2101.0
SharePointPnPPowerShellOnline 3.29.2101.0

Hi @harishpatil,

The Get-PnPComplianceTag cmdlet is a new cmdlet that was introduced in PnP PowerShell version 3.29.2101.0. If you are using an older version of PnP PowerShell, then you will not have this cmdlet and you will need to upgrade to a newer version.

To check the version of PnP PowerShell that you are using, run the following command:

 

Get-Module SharePointPnPPowerShellOnline -ListAvailable | Select-Object Version

 

 

If you are not using PnP PowerShell version 3.29.2101.0 or higher, then you can upgrade to the latest version by running the following command:

 

Install-Module SharePointPnPPowerShellOnline -Force

 

 

Once you have upgraded to the latest version of PnP PowerShell, you should be able to run the Get-PnPComplianceTag cmdlet without any errors.

If you are still having problems, please try the following:

  • Make sure that you are running the PowerShell script as an administrator.
  • Restart your computer.
  • Try running the PowerShell script in a different PowerShell console.

Please click Mark as Best Response & Like if my post helped you to solve your issue.
This will help others to find the correct solution easily. It also closes the item.


If the post was useful in other ways, please consider giving it Like.


Kindest regards,


Leon Pavesic

Hi Leon,

I have followed all steps you mentioned also restarting machine, run as Administrator. I have tried all the things.

I found that if I uninstall the All Version still I can see the below version. Not able to understant from where it takes. Also not getting any solution how to remove that. If I again try to uninstall same command then it says below message:

PackageManagement\Uninstall-Package : No match was found for the specified search criteria and module names 'SharePointPnPPowerShellOnline'.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.2.5\PSModule.psm1:12733 char:21

Still shows below version:

Name Version
---- -------
SharePointPnPPowerShellOnline 3.29.2101.0

Is there any way how we can remove the same or any other solution for the same.
I am getting the same error as harishpatil. I am trying to run the code you added above, and have the lastest version of SharePointPnPPowerShellOnline, but get the error: The term 'Get-PnPComplianceTag' is not recognized as the name of a cmdlet...