Solved

powershell script

Posted on 2013-12-06
12
348 Views
Last Modified: 2013-12-14
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
Comment
Question by:Cecilpierce
[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
  • 6
  • 5
12 Comments
 
LVL 40

Expert Comment

by:Subsun
ID: 39701663
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
 
LVL 70

Expert Comment

by:Qlemo
ID: 39701691
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
 

Author Comment

by:Cecilpierce
ID: 39701797
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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
LVL 40

Expert Comment

by:Subsun
ID: 39701890
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
 

Author Comment

by:Cecilpierce
ID: 39702153
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
 
LVL 40

Expert Comment

by:Subsun
ID: 39702168
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
 

Author Comment

by:Cecilpierce
ID: 39702310
file uploaded, i opened it in excel 2010
sampleps1.xlsx
0
 
LVL 40

Expert Comment

by:Subsun
ID: 39702734
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
 

Author Comment

by:Cecilpierce
ID: 39707566
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
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
ID: 39707791
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
 

Author Comment

by:Cecilpierce
ID: 39709290
ahh i see the mistake now and thanks for your help! results are as expected now.
0
 
LVL 40

Expert Comment

by:Subsun
ID: 39709514
Nice!!.. If you don't have any further questions, then please don't forget to close this question..
0

Featured Post

Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

Question has a verified solution.

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

Background Information Recently I have fixed file server permission issues for one of my client. The client has 1800 users and one Windows Server 2008 R2 domain joined file server with 12 TB of data, 250+ shared folders and the folder structure i…
Ever notice how you can't use a new drive in Windows without having Windows assigning a Disk Signature?  Ever have a signature collision problem (especially with Virtual Machines?)  This article is intended to help you understand what's going on and…
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …

737 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