list all files with no Owner set

Goal

When performing file migrations it can be difficult to set perms on files with long paths so being able to list all files with no Owner set can be really helpful.

Solution

$Path = "c:\Test"
$LogPath = "c:\test"
Get-ChildItem $Path -force -Recurse | Select Name,Directory,@{Name="Owner";Expression={(Get-ACL $_.Fullname).Owner}},CreationTime,LastAccessTime | Export-Csv $LogPath\FileFolderOwner.csv -NoTypeInformation

Found priceless insights in this blog? Support the author’s creativity – buy them a coffee!

Leave a Reply

Your email address will not be published. Required fields are marked *