Solved

Get the file ownership from .CSV file

Posted on 2013-06-19
2
638 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 8

Author Closing Comment

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

Featured Post

Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
A hard and fast method for reducing Active Directory Administrators members.
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 …
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

728 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