将文件名从循环文件写入文本文件

mkr*_*use 4 powershell

$fileEntries = [IO.Directory]::GetFiles("C:\Users\U0146121\Desktop\Example Data"); #where the file is located.
foreach($fileName in $fileEntries) 
{ 
 #write the file name to a text file.  
}  
Run Code Online (Sandbox Code Playgroud)

我需要将文件名写入循环中的文本文件,但我不知道如何.

最后,我将读取文本文件并在excel中搜索文件名.但是现在我必须首先编写.txt文件.

Kev*_*in_ 13

我测试了这个,它对我有用:

Get-childitem -path "C:\" -recurse -name | out-file C:\Output.txt
Run Code Online (Sandbox Code Playgroud)