remove more than 1 shadow
This commit is contained in:
@@ -117,12 +117,16 @@ If ( Test-Path $ADSKInst ) {
|
||||
}
|
||||
}
|
||||
|
||||
# Delete the oldest shadow copies if there are more than 1
|
||||
# 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 }
|
||||
If ( $ShadowCopies.Length -gt 1 ) {
|
||||
Write-Output "Deleting oldest shadow copy on ${Env:SystemDrive}"
|
||||
Write-Output "Deleting all of the oldest shadow copies on ${Env:SystemDrive}"
|
||||
$ShadowsToDelete = $ShadowCopies.Length - 1
|
||||
While ( $ShadowsToDelete -gt 0 ) {
|
||||
$ShadowsToDelete = $ShadowsToDelete - 1
|
||||
vssadmin delete shadows /For=$Env:SystemDrive /Oldest /Quiet
|
||||
}
|
||||
}
|
||||
|
||||
# Remove files from user profile directories
|
||||
|
||||
Reference in New Issue
Block a user