Avatar of Cecilpierce
Cecilpierce
Flag for United States of America asked on

powershell script

i have found a PS script that does what i need execpt that it does not seperate the information into seperate collums in the csv file so i can sort it by last write date see below:

get-childitem e:\pf_data -rec | where {!$_.PSIsContainer} | select-object FullName, LastWriteTime, Length | export-csv -notypeinformation -delimiter '|' -path c:\pf_data_files.csv
Microsoft Legacy OSMicrosoft Server OSWindows Server 2003

Avatar of undefined
Last Comment
SubSun

8/22/2022 - Mon
SubSun

Try removing -delimiter parameter from Export-csv command..
get-childitem e:\pf_data -rec | where {!$_.PSIsContainer} | select-object FullName, LastWriteTime, Length | export-csv -notypeinformation -path c:\pf_data_files.csv 

Open in new window

Qlemo

Correct. If you use a non-standard delimiter, you need to provide that on every import, unless the changed delimiter isn't the default in the importing application.
Example: In some countries, CSVs for Excel need to be separated by semi-colon instead of comma, since comma is the decimal sign.
Cecilpierce

ASKER
i took that part out and the output was not in seprate collums, just a single string

E:\pf_data\03-2010 107137 Loan Mod Report.xls|"3/16/2010 1:22:05 PM"|"607744"
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
SubSun

Did you run the command which I mentioned in my comment? It should give you a csv file which you can open in Excel.
Cecilpierce

ASKER
Yes I ran your command. But it puts the file name and last write time and size in the same cell I need each them in seprate cells
SubSun

Can you post the output file? also how did you open the file?

Also try adding the -Encoding for file (UTF8 or ASCII)..
get-childitem e:\pf_data -rec | where {!$_.PSIsContainer} | select-object FullName, LastWriteTime, Length | export-csv -notypeinformation -path c:\pf_data_files.csv -Encoding UTF8

Open in new window

⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Cecilpierce

ASKER
file uploaded, i opened it in excel 2010
sampleps1.xlsx
SubSun

I am still seeing delimiter as '|' in your file. Either you are not using the correct code or you are opening the wrong file. Also the output file should be csv not xlsx.
Cecilpierce

ASKER
below is the code i am running, i sent you an excel file because i just copyed some of the output, i see no reason to attach a 100MB file
 
get-childitem e:\pf_data -rec |where {!$_.PSIsContainer} | select-object FullName,LastWriteTime,Length | export-csv -notypeinformation '|' -path c:\pf_data_files.csv
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
ASKER CERTIFIED SOLUTION
SubSun

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Cecilpierce

ASKER
ahh i see the mistake now and thanks for your help! results are as expected now.
SubSun

Nice!!.. If you don't have any further questions, then please don't forget to close this question..