It appears you're encountering an issue with the Copy-PnPList
cmdlet in PnP PowerShell. The error message indicates that this cmdlet isn't recognized, which suggests one of several possibilities.
The Copy-PnPList
cmdlet was indeed available in older versions of PnP PowerShell, but it was removed in newer versions of the module. If you're using a recent installation of PnP PowerShell, this cmdlet is no longer available.
Here are a few things to check:
- Verify which version of PnP PowerShell you're running:
Get-Module PnP.PowerShell -ListAvailable
- The newer recommended approach is to use the
Export-PnPListToSiteTemplate
andInvoke-PnPSiteTemplate
cmdlets to copy lists between sites. - If you need this specific functionality, you might need to downgrade to an older version of PnP PowerShell where this cmdlet was still available.
To copy a list in current versions of PnP PowerShell, you can use a site template approach:
# Connect to source site
Connect-PnPOnline -Url "https://yourtenant.sharepoint.com/sites/sourceSite" -Interactive
# Export the list to a template
Export-PnPListToSiteTemplate -List "YourListName" -Out "list-template.xml" -IncludeAllPages
# Connect to destination site
Connect-PnPOnline -Url "https://yourtenant.sharepoint.com/sites/destinationSite" -Interactive
# Apply the template
Invoke-PnPSiteTemplate -Path "list-template.xml"