Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to find out all files and their appropriate paths on drive using powershell?

Posted on 2009-12-18
6
Medium Priority
?
283 Views
Last Modified: 2013-11-10
Hi All,

Just need PS script which will display me all files and their paths in second column for example on some hard drive.
Lets say that I have "C:\" hard drive and i'm interesting to see all files with their paths.

I find out this code:

$Path = "d:\backups"
$a = get-Childitem $Path -recurse | format-table -group{$_.Path} name, directory -autosize
$a

but it works only for backups folder, when I replace it to "d:\" it doesn't work I get message: WARNING: column "directory" does not fit into the display and was removed.

So folks, what I'm doing wrong?

Thanks for answer in advice.

Best Regards.
0
Comment
Question by:davidzak
  • 2
  • 2
  • 2
6 Comments
 
LVL 1

Expert Comment

by:doug_hale_jr
ID: 26080228
Have your tried setting the path $Path="d:" without the backslash?
0
 

Author Comment

by:davidzak
ID: 26080377
Yes, unfortunately same behavior...
0
 
LVL 1

Expert Comment

by:doug_hale_jr
ID: 26080976
I think the problem is generated becuase as it recurses down through the directories, the output for directory gets progressivly longer and ultimately will not fit in the display.  Perhaps adding wrap will help.  Try the following:

$Path = "d:\"
$a = get-Childitem $Path -recurse | format-table -group{$_.Path} name, directory -wrap -autosize
$a
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Accepted Solution

by:
ilangal earned 750 total points
ID: 26118463
I have test this syntax in both PS1.0 and 2.0 and it worked fine at three machines -

$Path = "D:\"
$a = get-Childitem $Path -recurse | format-table -group{$_.Path} name, directory -autosize
$a
0
 

Author Closing Comment

by:davidzak
ID: 31667736
I want to see this one: get-Childitem "c:\" -force -recurse | format-table -group{$_.Path} name, directory | out-file -width 250 "c:\foo.txt"
0
 
LVL 1

Expert Comment

by:ilangal
ID: 26286030
You may also try working with CSV file -

get-Childitem "c:\" -force -recurse |Select-Object Name,FullName |Export-Csv "c:\foo.csv"

Open in new window

0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

This is about my first experience with programming Arduino.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Loops Section Overview

810 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