Important Notice: On February 29th, this community was put into read-only mode. All existing posts will remain but customers are unable to add new posts or comment on existing. Please feel to join our Community Discord for any questions and discussions.

Help getting vssadmin/shadow copies max size (WMI/PowerShell)


I would like to be able to get the value of 'Maximum Shadow Copy Storage Space', which is the maximum % of the drive available for storing shadow copies. I'm only interested in the C: drive, which can be shown by running

vssadmin list shadowstorage /for=C:

Example output - result shows 10%

Shadow Copy Storage association
   For volume: (C:)\\?\Volume{ad6dd63c-7d44-479e-a2ad-96dbd334cd26}\
   Shadow Copy Storage volume: (C:)\\?\Volume{ad6dd63c-7d44-479e-a2ad-96dbd334cd26}\
   Used Shadow Copy Storage space: 20.7 GB (8%)
   Allocated Shadow Copy Storage space: 21.5 GB (9%)
 Maximum Shadow Copy Storage space: 23.1 GB (10%)

Using WMI, I can get the DeviceID for the C: drive

Get-WmiObject -Class "Win32_volume" | Where-Object {$_.Name -Like "C:\"} | Select DeviceID, Name, Capacity

Output is 

DeviceID                                          Name     Capacity
--------                                          ----     --------
\\?\Volume{ad6dd63c-7d44-479e-a2ad-96dbd334cd26}\ C:\  248154189824

So far so good. Now I can use WMI again to query the ShadowStorage stuff

Get-WmiObject -Class "Win32_shadowstorage" | Select-Object Volume, Maxspace

Output is 

Volume                                                                            MaxSpace
------                                                                            --------
Win32_Volume.DeviceID="\\\\?\\Volume{ad6dd63c-7d44-479e-a2ad-96dbd334cd26}\\"  24815419289
Win32_Volume.DeviceID="\\\\?\\Volume{6a8b80d5-fc08-4217-a848-f8d661416919}\\" 500094520524
Win32_Volume.DeviceID="\\\\?\\Volume{db66cfc2-0000-0000-0000-800200000000}\\"  75011247308

Okay... here is where I'm stuck...

I have 3 drives in this computer, but I'm only interested in the C: drive, so need to filter this command to include only the DeviceID from above, but not sure how.

I then need to take the value for MaxSpace and divide that by Capacity (then multiple by 100, then remove all the decimal places) to get a clean % figure. In this case, 10%.

Can anyone help? Thanks in advance.



1 comment
Date Votes
  • Hey, came across this post today while I was trying to figure out the same thing. This worked for me. I'm just stripping some of the volume ID so I can get a match

    $wmi = Get-WmiObject -Class "Win32_volume" | Where-Object {$_.Name -Like "C:\"} | Select DeviceID, Name, Capacity
    $id = $wmi.DeviceID.Replace("`\","")
    $id = $id.replace("?Volume{","")
    $gb = Get-WmiObject -Class "Win32_shadowstorage" | Where{$_.Volume -match $id} | Select-Object Volume, MaxSpace