Using PnPonline to audit a site for file changes and ownership #443
-
I'm trying to use the pnponline module to get audit information on one of our document sites. I can connect to the site and get a listing of files and folders using get-pnpfolderitem but there are some details I can't get - author and modifiedby, those filed come up blank. I can throw all the files into an array and some of the fields I can get data back on, file.name, file.path.identity, file,timecreated, file.timelast modified but the important ones (author and modifiedby) are becoming a mystery. If I try to pipe the variable file|fl I get this error - "the collection has not been initialized. It has not been requested or the request has not been executed". I don't know where else to try and figure this out. I opened a case with Microsoft and they referred me to this forum. Any help or ideas would be appreciated - thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Hi @SacJones, |
Beta Was this translation helpful? Give feedback.
-
The following is working for me: $allFiles = Get-PnPListItem -List "Documents"
$results = @()
foreach($file in $allFiles){
$results += [pscustomobject]@{
fileName = $file["FileLeafRef"]
CreatedBy = $file.FieldValues.Author.LookupValue
ModifiedBy = $file.FieldValues.Editor.LookupValue
}
}
$results |
Beta Was this translation helpful? Give feedback.
The following is working for me: