Programitcally determine if Shadow Copies are enabled on a particular volume


Is anyone aware of a method for checking if Shadow Copies are enabled on a volume programatically.  I need to check a lot of servers, and having looked through the WMI classes, I can't find any that say whether the copies are enabled.


Who is Participating?
sr75Connect With a Mentor Commented:
There is a WMI class for that.  I have attached a site with various shadow copy scripts

the attached code may actually provide what you are looking for:

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_ShadowCopy")
For Each objItem in colItems
    Wscript.Echo "ID: " & objItem.ID
    Wscript.Echo "Client accessible: " & objItem.ClientAccessible
    Wscript.Echo "Count: " & objItem.Count
    Wscript.Echo "Device object: " & objItem.DeviceObject
    Wscript.Echo "Differnetial: " & objItem.Differential
    Wscript.Echo "Exposed locally: " & objItem.ExposedLocally
    Wscript.Echo "Exposed name: " & objItem.ExposedName
    Wscript.Echo "Exposed remotely: " & objItem.ExposedRemotely
    Wscript.Echo "Hardware assisted: " & objItem.HardwareAssisted
    Wscript.Echo "Imported: " & objItem.Imported
    Wscript.Echo "No auto release: " & objItem.NoAutoRelease
    Wscript.Echo "Not surfaced: " & objItem.NotSurfaced
    Wscript.Echo "No writers: " & objItem.NoWriters
    Wscript.Echo "Originating machine: " & objItem.OriginatingMachine
    Wscript.Echo "Persistent: " & objItem.Persistent
    Wscript.Echo "Plex: " & objItem.Plex
    Wscript.Echo "Provider ID: " & objItem.ProviderID
    Wscript.Echo "Service machine: " & objItem.ServiceMachine
    Wscript.Echo "Set ID: " & objItem.SetID
    Wscript.Echo "State: " & objItem.State
    Wscript.Echo "Transportable: " & objItem.Transportable
    Wscript.Echo "Volume name: " & objItem.VolumeName

Open in new window

Couldn't you just check that the service is running on each server?
lambch0pAuthor Commented:
Thanks. but it's possible for the service to be running without any shadow copies being configured.

I had found this code before, but couldn't see any method or property that indicated if shadow copies were enabled.

However, i've just done some testing, and if Shadow Copies aren't enabled, then this management class doesn't return anything, if a shadow copy exists, it is returned by this class.  The volume name property can be used to query the win32_volume class, from which the caption property shows the drive letter.
All Courses

From novice to tech pro — start learning today.