Часть Powershell:
- Получает сопоставления дисков
- Проверяет, занимают ли они в них место (вероятно, все)
- Проходит через них иудаляет все файлы в папках Windows10Upgrade с расширением
.esd
например
M:\Windows10Upgrade\*.esd
S:\Windows10Upgrade\*.esd
T:\Windows10Upgrade\*.esd
См. ниже закомментированную версию кода, поясняющую каждую строку:
# Get shared drives
Get-PSDrive -PSProvider FileSystem |
# Filter just those with used space
Where-Object { $_.Used -gt 0 } |
# Go through each of those drives
ForEach-Object {
# Set a variable with the Windows10Upgrade folder and *.esd wildcard
$esdOriginalFilePath = 'C:\Windows10Upgrade\\*.esd';
# Get the drive name for the one currently in the loop ($_)
$driveName = $_.Name;
# Use a regex replace of the first 'word' character with drivename (e.g. C -> E, C -> W)
$esdFilePath = $esdOriginalFilePath -replace '^\w',$driveName;
# Check if the path exists
if (Test-Path $esdFilePath)
# If so, remove the file
{ Remove-Item $esdFilePath }
}
Я бы предложил запустить это в Powershell:
Get-PSDrive -PSProvider FileSystem |
Where-Object { $_.Used -gt 0 }
Чтобы получить представление о том, как это работает.