/build/static/layout/Breadcrumb_cap_w.png

Determine drives that have System Restore enabled

I modified a Powershell script posted by austinmartinez2 at Spiceworks Sort ShadowCopies by Volume so that I could determine which drives have System Restore enabled.

I tried to make the output appear the way the information is presented in the control panel. Tested in Windows 7 SP1 and Windows 10 1809.

# Sort ShadowCopies by Volume

# https://community.spiceworks.com/topic/2155972-sort-shadowcopies-by-volume
# Original by austinmartinez2 Spiceworks

$shadowStorageList = @();
$volumeList = Get-WmiObject Win32_Volume -Property DriveLetter,DeviceID,Capacity,FreeSpace -Filter "DriveType=3 and FileSystem='NTFS'" | select @{n="DriveLetter";e={$_.DriveLetter.ToUpper()}},DeviceID,@{n="CapacityGB";e={([math]::Round([int64]($_.Capacity)/1GB,2))}},@{n="FreeSpaceGB";e={([math]::Round([int64]($_.FreeSpace)/1GB,2))}} | Sort DriveLetter;
$shadowStorages = gwmi Win32_ShadowStorage -Property AllocatedSpace,DiffVolume,MaxSpace,UsedSpace,Volume |
Select @{n="Volume";e={$_.Volume.Replace("\\","\").Replace("Win32_Volume.DeviceID=","").Replace("`"","")}},
@{n="DiffVolume";e={$_.DiffVolume.Replace("\\","\").Replace("Win32_Volume.DeviceID=","").Replace("`"","")}},
@{n="AllocatedSpaceGB";e={([math]::Round([int64]($_.AllocatedSpace)/1GB,2))}},
@{n="MaxSpaceGB";e={([math]::Round([int64]($_.MaxSpace)/1GB,2))}},
@{n="UsedSpaceGB";e={([math]::Round([int64]($_.UsedSpace)/1GB,2))}}

$volumeList | Where-Object {$_.DriveLetter -ne $Null} | ForEach-Object {
$DeviceID = $_.DeviceID
$DriveLetter = $_.DriveLetter
$DriveCapacityGB = $_.CapacityGB
$Protection = "Off"
#$AllocatedSpaceGB = ""
$UsedSpaceGB = ""
$MaxSpaceGB = ""
$MaxSpacePercent = ""

foreach ($shStorage in $shadowStorages) {
if ($shStorage.Volume -eq $DeviceID) {
$Protection = "On"
#$AllocatedSpaceGB = $shStorage.AllocatedSpaceGB
$UsedSpaceGB = $shStorage.UsedSpaceGB
$MaxSpaceGB = $shStorage.MaxSpaceGB
$MaxSpacePercent = "{0:P0}" -f ($MaxSpaceGB / $DriveCapacityGB)
}
}

$objVolume = New-Object PSObject -Property @{
DriveLetter = $DriveLetter
Protection = $Protection
#AllocatedSpaceGB = $AllocatedSpaceGB
UsedSpaceGB = $UsedSpaceGB
MaxSpaceGB = $MaxSpaceGB
MaxSpacePercent = $MaxSpacePercent
}
$shadowStorageList += $objVolume;
}

$shadowStorageList | Select DriveLetter, Protection, UsedSpaceGB, MaxSpaceGB, MaxSpacePercent


Comments

This post is locked

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ