Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Powershell listing of all files and owner to CSV

$
0
0

Hi Everyone, I have been working with PS for a very short time; but have pieced together a couple of approaches, neither is perfectat this stage.

Option 1:

Get-ChildItem C:\Projects -recurse | where {$_.attributes -ne "Directory"} | foreach {$_.DirectoryName,$_.Name,$_.Length,(Get-ACL).Owner} | Export-CSV C:\Projects\Filelist.csv

Option 2:

Get-ChildItem C:\Projects -recurse | where {$_.attributes -ne "Directory"} | Select-Object DirectoryName,Name,Length,(Get-ACL).Owner | Export-CSV C:\Projects\Filelist.csv

My end goal is to have a CSV file that show the Directory, filename, size and owner.

Right now I either get an empty file or one with repeating values that do not resemble the data that I require.

Eventually, I want to parameterize the input so that the script would take in the variable during execution. Given that I would want to repeat this over and over again with various users to get statistics on their files and folders.

Thanks.


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>