我要从3个目录中提取3个目录。我设置了一个GUI以输出$year变量。选项为2017、2018、2019和全选。对于文件,我想将它们复制到其他文件夹,最好保留完整的文件夹结构。
$year = '2018'
if ($year = '2017') {
Get-ChildItem -Path $sourcePath'\Warranty Claims 2017' -Recurse
} elseif ($year = '2018') {
Get-ChildItem -Path $sourcePath'\Warranty Claims 2018' -Recurse
} elseif ($year = '2019') {
Get-ChildItem -Path $sourcePath'\Warranty Claims 2019' -Recurse
} elseif ($year = 'Select All') {
Get-ChildItem -Path $sourcePath'\Warranty Claims 2017'
Get-ChildItem -Path $sourcePath'\Warranty Claims 2018'
Get-ChildItem -Path $sourcePath'\Warranty Claims 2019'
} else {
"This didn'nt work"
}
# = files
Run Code Online (Sandbox Code Playgroud)
这就是想法,它不起作用。由于以下代码,我希望将此输出放入变量$ files中。我乐于接受替代方法,但是从新手的角度来看,这似乎是最合乎逻辑的。
foreach ($file in $files){
$sourcePathFile …Run Code Online (Sandbox Code Playgroud)