我正在尝试将文件列表保存在目录到数组列表中,请您共享Windows PowerShell的代码段。
我在c:\ temp下有2个文件
file1:stack.zipfile2:overflow.zip
需要将文件1和文件2存储在名为数组中的>]
$arrlst = ['stack.zip','overflow.zip']
Set-Location -Path "c:\temp"
fileslst = Get-children
$arrlst = [filelist]
我正在尝试将文件列表保存在目录到数组列表中,请您共享Windows PowerShell的代码段。我在c:\ temp file1下有2个文件:stack.zip file2:overflow.zip ...
运行下面的内容将为您提供所需要的。
$scriptpath='c:\temp'
$fileNames = Get-ChildItem -File -Path $scriptPath -Recurse -Include *.zip | Select -ExpandProperty Name
foreach ($vinodh in $fileNames)
{
write-host $vinodh
}