Solved

Get the file ownership from .CSV file

Posted on 2013-06-19
2
635 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
[X]
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
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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

In-place Upgrading Dirsync to Azure AD Connect
This article shows the method of using the Resultant Set of Policy Tool to locate Group Policy that applies a particular setting.
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 configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

733 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