This appears to work.
# Get the full list of files ls '\\server\share\folder' -File -Recurse | # Limit to files with the right age and owner where {($_.lastwritetime -lt "$age") -and ((get-acl $_.FullName).owner -eq "domain\user")} | # Add an Owner column to the object ForEach-Object {$_ | Add-Member -type NoteProperty -name Owner -value (Get-ACL $_.FullName).Owner -PassThru} | # Get just the filename and the owner select-object fullname, owner | # Format the output ft -AutoSize
Also, a couple of tips.
- You had used the escape character at the end of each line. The pipe character will let you carry over to the next line, so there was no need for the escape.
- Also,
Where-Object
uses{
and}
to define the script block. Grouping conditions within the script block can be done using(
and)
.