We help IT Professionals succeed at work.
Get Started

Powershell script to get file properties to a CSV file

Last Modified: 2012-05-09

I have requirement to capture following file properties using powershell.

I am using Get-childitem to get following.

$1= Get-ChildItem -recurse | Select-Object Name
$2= Get-ChildItem -recurse | Select-Object CreationTime
$3= Get-ChildItem -recurse | Select-Object LastAccessTime
$4= Get-ChildItem -recurse | Select-Object LastWriteTime
$5= Get-ChildItem -recurse | Select-Object Fullname

Then using $5 variable I wanted to run Get-Acl (only owner) to get the owner. But that is not working.
At the end I would like to have all the results in a single CSV file. like below.
Name -  Owner- CreationTime - LastAccessTime - LastWriteTime - Fullname.

I have couple of problems
1- There are file names with space in it. So when using Fullname variable ($5) I have to put double quotes..Note sure how to add double quotes.

2- Even though I get results using Get-Acl not sure how to merge all the columns in to single CSV file.

Appreciate your help.

Watch Question
PowerShell Developer
Top Expert 2010
This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE