大家都投票給你,因爲你沒有付出努力。下面可以用來找到你想要的。這是醜陋而短暫的,但會完成你所要求的。今後請提供更多信息和代碼。
$dir = read-host "Please Enter Directory to Search."
$nameOfBadFile = Read-Host "The name of the bad file, including extension"
$goodImg = read-host "Full location of your known good file (C:\somefile.txt)."
$i=0;
foreach($file in (Get-ChildItem $dir -Recurse | ?{$_.Name -eq $nameOfBadFile}))
{
$file.Delete()
$i++;
Write-Host "Just Deleted an instance of the bad image. You Have deleted $i images so far."
$goodimg | Copy-Item -Destination $file.Directory
Write-Host "Copied good file to current directory, $file.Directory"
}
你到目前爲止試過了什麼?編輯你的問題併發布一些代碼。 – Jelphy
_回覆!_。你嘗試了什麼? [mcve],[問] – Manu