Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 356
  • Last Modified:

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
0
Cecilpierce
Asked:
Cecilpierce
  • 6
  • 5
1 Solution
 
SubsunCommented:
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

0
 
QlemoC++ DeveloperCommented:
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.
0
 
CecilpierceAuthor Commented:
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"
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
SubsunCommented:
Did you run the command which I mentioned in my comment? It should give you a csv file which you can open in Excel.
0
 
CecilpierceAuthor Commented:
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
0
 
SubsunCommented:
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

0
 
CecilpierceAuthor Commented:
file uploaded, i opened it in excel 2010
sampleps1.xlsx
0
 
SubsunCommented:
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.
0
 
CecilpierceAuthor Commented:
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
0
 
SubsunCommented:
You didn't remove '|' from command.. Copy paste following code to your powershell console and hit Enter..

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

0
 
CecilpierceAuthor Commented:
ahh i see the mistake now and thanks for your help! results are as expected now.
0
 
SubsunCommented:
Nice!!.. If you don't have any further questions, then please don't forget to close this question..
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now