Avatar of fireguy1125

asked on 

Powershell Script to Export Filenames and Directories by Owner

I need a script I can run in a directory where I can list all files, their names, directories by a specific owner.  I'm presently using this script I found:

$arr = @()
gci "F:\Shares" -recurse | ? {$_.PSIsContainer -eq $False} | % {
  $obj = New-Object PSObject
  $obj | Add-Member NoteProperty Directory $_.DirectoryName
  $obj | Add-Member NoteProperty Name $_.Name
  $obj | Add-Member NoteProperty Length $_.Length
  $obj | Add-Member NoteProperty Owner ((Get-ACL $_.FullName).Owner)
  $arr += $obj
  $arr | Export-CSV -notypeinformation "c:\fileowner.csv"

Open in new window

This is good, but I would like to have the search performed by Owner instead, and output the directory and name of those that are associated with the specified owner.
PowershellScripting Languages

Avatar of undefined
Last Comment
Jason Ryberg

8/22/2022 - Mon