【发布时间】:2014-09-04 23:52:45
【问题描述】:
我正在尝试创建一个 powershell 脚本,该脚本将检查文件夹中的 3 个特定文件。如果 3 个文件存在则继续。
我一直在尝试使用 test-path 命令。我得到的最接近的是:
$checkwim = test-path $imagepath\* -include OS.wim, data.wim, backup.wim.
但这对我不起作用,因为如果找到 3 个中的任何一个,它就会返回“True”。我需要确保所有 3 个都存在。
我使用下面的方法让它工作,但我希望有一个更简单\更短的方法。
$checkwimos = test-path $imagepath\* -include OS.wim
$checkwimdata = test-path $imagepath\* -include Data.wim
$checkwimonline = test-path $imagepath\* -include Online.wim
if (($checkwimos -ne $True) -or ($checkwimdata -ne $True) -or ($checkwimonline -ne $True))
{
Echo "WIM file(s) not located. Script Aborting"
exit
}
有没有更简单的方法来做到这一点?
【问题讨论】: