List only file names with PowerShell
By default, listing the contents of a directory with
PowerShell
shows file metadata along with the path names within the directory.
Other shells typically show only the path names by default, which is convenient for copy-pasting lists of files or directories into other commands or scripts.
To list only the path names when listing a directory in PowerShell, use the -Name
option:
Get-ChildItem -Name
# or
ls -Name