Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从PowerShell目录中的特定文件夹获取文件_Powershell_Powershell 3.0_Powershell 4.0 - Fatal编程技术网

从PowerShell目录中的特定文件夹获取文件

从PowerShell目录中的特定文件夹获取文件,powershell,powershell-3.0,powershell-4.0,Powershell,Powershell 3.0,Powershell 4.0,我在一个目录中有4个文件夹。所有这些文件夹都包含一些文件。我只想列出这两个文件夹中的文件名 C:\MainFolder\FolderOne\FileOne.txt C:\MainFolder\FolderTwo\FileTwo.txt C:\MainFolder\FolderThree\FileThree.txt C:\MainFolder\FolderFour\FileFour.txt 我只想列出FolderTwo和FolderThree下的文件 如果我使用-Recurse-Include“

我在一个目录中有4个文件夹。所有这些文件夹都包含一些文件。我只想列出这两个文件夹中的文件名

C:\MainFolder\FolderOne\FileOne.txt
C:\MainFolder\FolderTwo\FileTwo.txt
C:\MainFolder\FolderThree\FileThree.txt
C:\MainFolder\FolderFour\FileFour.txt
我只想列出FolderTwo和FolderThree下的文件

如果我使用
-Recurse-Include“FolderNames”
它将只列出文件夹名称。

是这样做的吗

get-childitem -recurse 'foldertwo','folderthree'
$arrPath ='C:\MainFolder\FolderTwo','C:\MainFolder\FolderThree'

get-childitem -recurse $arrPath

getchilditem'C:\MainFolder\FolderTwo';获取ChildItem“C:\main folder\FolderThree”
它可以工作,谢谢!它与“get childitem-recurse”C:\MainFolder\FolderTwo”和“C:\MainFolder\FolderTwo”一起工作`
$arrPath ='C:\MainFolder\FolderTwo','C:\MainFolder\FolderThree'

get-childitem -recurse $arrPath