I need to get the owner of files which I have the list in .CSV file as the absolute folder path so that I add the result in secondary column which list the owner of the files.
Thanks in advance.
The first column of the CSV:
G:\Directory1\file1.zip
H:\Directory3\file4.docx
.
.
.
F:\Directory99\file234324.bat
The second column is none, but I'd like it to be:
Username1
Username2
.
.
.
Username99
If you just have a line-separated list of files, it's not a csv file - it's just a text file.
You could check if each file exist and use
Get-Acl
to provide the ownership information:You can use
Select-Object
and a calculated property to generate the CSV.Note that your question indicates there is no header in the source CSV file. I'm adding the headings of "File" and "Owner" to the output.