stop shadow copy cleaner from showing error on 0 shadows

This commit is contained in:
2025-08-15 15:55:11 -04:00
parent 49b0f25369
commit 432133775a
+1 -1
View File
@@ -138,7 +138,7 @@ If ( Test-Path $ADSKInst ) {
# Delete all but most recent shadow copy of system drive
$SystemVolume = Get-CimInstance -ClassName Win32_Volume -ErrorAction SilentlyContinue | Where-Object { $_.Name -like "${Env:SystemDrive}\" }
$ShadowCopies = Get-CimInstance -ClassName Win32_ShadowCopy | Where-Object { $_.VolumeName -like $SystemVolume.DeviceID }
$ShadowCopies = Get-CimInstance -ClassName Win32_ShadowCopy -ErrorAction SilentlyContinue | Where-Object { $_.VolumeName -like $SystemVolume.DeviceID }
If ( $ShadowCopies.Count -gt 1 ) {
Write-Output "Deleting all of the oldest shadow copies of ${Env:SystemDrive}"
$ShadowsToDelete = $ShadowCopies.Count - 1