Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Get the file ownership from .CSV file

Posted on 2013-06-19
2
634 Views
Last Modified: 2013-06-19
Hi,

I wonder if this is possible with Powershell script, I need to get the owner of files which I have the list in .CSV file as the absolute folder path so that I can get the result in secondary column which list the owner of the files.

The first column of the CSV:
F:\Directory1\file1.zip
H:\Directory3\file4.docx
.
.
.
F:\Directory99\file234324.bat

The second column is none, but I'd like it to be:
Logonname1
Logonname2
.
.
.
Logonname99

Thanks.
0
Comment
2 Comments
 
LVL 40

Accepted Solution

by:
footech earned 500 total points
ID: 39261258
Code is a little different depending on whether the file you already have is a CSV (and what (if any) headers are present) or just a text file with the file names.  I'm going to assume a simple text file without any commas for the input.
(Get-Content .\files.csv) | ForEach { New-Object PsObject -property @{ name = $_; owner = (Get-Acl $_).owner}} | Export-Csv files.csv -notype

Open in new window

This will write back to the original file, but you could change the file being written to with Export-CSV if you want to write to a different file and leave the original alone.
0
 
LVL 7

Author Closing Comment

by:Senior IT System Engineer
ID: 39261271
Thanks !
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This article describes my battle tested process for setting up delegation. I use this process anywhere that I need to setup delegation. In the article I will show how it applies to Active Directory
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question