Link to home
Start Free TrialLog in
Avatar of moorthy_kulumani
moorthy_kulumani

asked on

Powershell script to get file properties to a CSV file


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.


ASKER CERTIFIED SOLUTION
Avatar of Chris Dent
Chris Dent
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of moorthy_kulumani
moorthy_kulumani

ASKER

You are the man....I tried expression but i think i screwed it up with some comma,double & single quotes etc...In your quote i removed one single quote between FullName, `  @.

Have a good day...