Skip to content

Conversation

@alirobe
Copy link
Contributor

@alirobe alirobe commented Sep 4, 2025

Type

  • Bug Fix
  • New Feature
  • Sample

Related Issues?

#5071

What is in this Pull Request ?

Copy-PnPFileMetadata cmdlet and docs

@alirobe
Copy link
Contributor Author

alirobe commented Sep 4, 2025

Please ignore this for a few hours, I am working on some perf optimizations and simplifications. Will put another comment in when I am done.

@alirobe
Copy link
Contributor Author

alirobe commented Sep 4, 2025

OK, hopefully that's done. Ready for review :)

@erwinvanhunen
Copy link
Member

Very nice one! Thank you very much!

@erwinvanhunen erwinvanhunen merged commit f3165cc into pnp:dev Oct 3, 2025
5 checks passed
@tborchardt
Copy link

Good morning team,

This is my first post in this GitHub repository, or github in general, so my apologies if i should post this comment as a new issue. I was just looking for confirmation if this cmdlet supports subsites because I'm having some issues getting it to copy metadata from one to a new site. Below is the code I'm running, with the domain name and client id redacted in the connection.

$src = Connect-PnPOnline -Url https://xyz.sharepoint.com/sites/storeengineering/retailfacilities -Interactive
$dst = Connect-PnPOnline -Url https://xyz.sharepoint.com/sites/retailfacilities -Interactive

Copy-PnPFileMetadata -SourceUrl "Shared Documents/Manuals" -TargetUrl "Shared Documents/Manuals" -SourceConnection $src -TargetConnection $dst -Verbose

When I attempt to run this, it comes back saying the source path '/sites/retailfacilities/shared documents/manuals' not found.

I've tried changing the src connection to just https://xyz.sharepoint.com and then in the "Copy" command I used /sites/storeengineering/retailfacilities/Shared Documents/Manuals

Any guidance is greatly appreciated. If I can get this command to run, this will truly be a lifesaver for me as I work on promoting subsites to their own site.

@alirobe
Copy link
Contributor Author

alirobe commented Nov 10, 2025

Hmm.. Are you sure the path for the documents is actually 'Shared Documents' and not just 'Documents'?

Edit: on desktop now, and I see you're using a subsite. Didn't catch that at first, but for a subsite I think you should be connecting to the parent site and including the subsite in the path. Can you give that a try? @tborchardt

I will review this later, confirm, and update docs if necessary.

@tborchardt
Copy link

Hmm.. Are you sure the path for the documents is actually 'Shared Documents' and not just 'Documents'?

Edit: on desktop now, and I see you're using a subsite. Didn't catch that at first, but for a subsite I think you should be connecting to the parent site and including the subsite in the path. Can you give that a try? @tborchardt

I will review this later, confirm, and update docs if necessary.

I was able to confirm that we need to connect to the parent site and then include the subsite in the path.

It was able to successfully copy the default fields, except the user mapped ones. It says, "Applied non-user fields after user mapping failure." after each file it copied metadata for.

@higgins0
Copy link

higgins0 commented Nov 18, 2025

So happy you worked on this, being unable to achieve these fields update has been killing me in the last week using all sorts of context like PNP/CSOM. I know i can do it with REST but it's heavy (i'm a beginner).
I'm also facing the "Applied non-user fields after user mapping failure.". Does it have something to do with access to to user mapping information? Should we do something about the connection scope or credentials scope used?
[Update] eventually got the CSOM approach to work : was missing sufficient right on the sharepoint application associated to my user (my comment above led me to dig that way). Anyway, it would be so convenient if you can solve the is issue as that PNP cmdlet would be so much simpler to use...:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants