Solved

Get the file ownership from .CSV file

Posted on 2013-06-19
2
622 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 39

Accepted Solution

by:
footech earned 500 total points
Comment Utility
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
Comment Utility
Thanks !
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Find out how to use Active Directory data for email signature management in Microsoft Exchange and Office 365.
This article will help you understand what HashTables are and how to use them in PowerShell.
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now