PowerShell/Scripts/list-files.ps1

18 lines
485 B
PowerShell
Raw Normal View History

2020-12-29 15:14:21 +01:00
<#
2021-04-21 19:53:52 +02:00
.SYNTAX list-files.ps1 [<dir-tree>]
.DESCRIPTION lists all files in the given directory tree
2021-03-22 20:10:18 +01:00
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
2020-12-29 15:14:21 +01:00
#>
2020-12-21 15:46:55 +01:00
2021-04-21 19:53:52 +02:00
param($DirTree = "")
if ($DirTree -eq "" ) { $DirTree = read-host "Enter path to directory tree" }
2020-12-21 15:46:55 +01:00
try {
2021-04-21 19:53:52 +02:00
Get-ChildItem -path $DirTree -recurse | select FullName
2020-12-21 15:46:55 +01:00
exit 0
} catch {
2021-02-16 10:03:20 +01:00
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
2020-12-21 15:46:55 +01:00
exit 1
}