From 432133775ad0ba621d1d2f4dcea904f20cf48231 Mon Sep 17 00:00:00 2001 From: David Yoder Date: Fri, 15 Aug 2025 15:55:11 -0400 Subject: [PATCH] stop shadow copy cleaner from showing error on 0 shadows --- Cleanup-SystemTempFiles.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cleanup-SystemTempFiles.ps1 b/Cleanup-SystemTempFiles.ps1 index 63b7382..2d72c91 100644 --- a/Cleanup-SystemTempFiles.ps1 +++ b/Cleanup-SystemTempFiles.ps1 @@ -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