Skip to content

Best way to set a files modified datetime #1853

Answered by davepile
davepile asked this question in Q&A
Discussion options

You must be logged in to vote

I found what I was looking for.

As mentioned in the question I was processing a $fileList obtained using Get-PnPFolderItem

The solutions for changing the file modified date all used a list item.

I was already using Get-PnPFile but hadn't noticed the -AsListItem option

Anyway this worked for me

 foreach($file in $fileList) { 

      $listItem = Get-PnPFile -Url $file.ServerRelativeUrl -AsListItem

      Set-PnPListItem -List 'Documents' -Identity $listItem.Id -Values @{"Modified"=$dt; } # | Out-Null
  }

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by davepile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant