Link to home
Start Free TrialLog in
Avatar of luketr
luketr

asked on

Powershell script to output a list of files that are in folders and subfolers.

Hi,

I need to write a power shell script that will output to a text file all the files that are in a directory including files in sub folders. .

Thanks

Luke
ASKER CERTIFIED SOLUTION
Avatar of KenMcF
KenMcF
Flag of United States of America 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 Qlemo
Since PSIsContainer is a boolean value, it is more straightforward to omit comparision (which is redundant):
Get-ChildItem c:\temp -Recurse | Where {!$_.PSIsContainer} | out-file c:\temp\files.txt

Open in new window

You can use aliases, which are a matter of taste:
gci c:\temp -recurse | ? {!$PSIsContainer] | out-file c:\temp\files.txt

Open in new window