Im looking for some help on information on files using Power shell, we have got most of when we need apart from the owner information.
the code below returns a list of directories that are older then 1 year, but the problem is we cannot seem to get the Owner Information to show in there:
gci -r
"D:\Network Shares\ICT\ICT\Network Shares\ICT\Innovations\Robert Pitt" | ?
{
$_.LastWriteTime -lt (Get-Date).AddYears(-1)} >> D:\temp\ICTFileAge.txt
}
We know of the command called Get-ACL
, but were unsure how to tie it all up.
Anyone have any ideas please, thanks
Something like this?
gci -r "D:\Network Shares\ICT\ICT\Network Shares\ICT\Innovations\Robert Pitt" |
? {$_.LastWriteTime -lt (Get-Date).AddYears(-1)} |
% {$_ | add-member -name "Owner" -membertype noteproperty -value (get-acl $_.fullname).owner -passthru} |
Select fullname,lastwritetime,owner