Windows: VSS shadow copies and vssadmin
vssadmin, diskshadow and WMI commands to inspect VSS writers, manage shadow copies and read locked files.
The Volume Shadow Copy Service (VSS) creates point-in-time snapshots of volumes. This article lists the commands to inspect writers, create and delete shadow copies, resize their storage, and read files that are in use.
Check the VSS writers
A failing VSS writer is a common cause of backup failures (for example with Veeam). Look for writers in an error state:
vssadmin list writers
A frequently suggested fix for SQL Server backups is to stop and start the SQLWriter service, then check the writers again. See this Veeam/VSS troubleshooting article.
List and manage shadow copies
vssadmin list writers
vssadmin list providers
vssadmin list shadows
vssadmin list shadowstorage
vssadmin list volumes
vssadmin delete shadows /all
Get-CimClass -ClassName *shadow
Resize the shadow copy storage
vssadmin resize shadowstorage /for=D: /on=D: /maxsize=401MB
vssadmin resize shadowstorage /for=D: /on=D: /maxsize=unbounded
Expected result: Successfully resized the shadow copy storage association.
Diskshadow
diskshadow
DISKSHADOW> list shadows all
DISKSHADOW> delete shadows all
List volumes with WMI
wmic
path Win32_Volume get DeviceID, DriveLetter, DriveType
Create a shadow copy
With PowerShell, through the Win32_ShadowCopy WMI class:
powershell.exe -Command (gwmi -list win32_shadowcopy).Create('E:\','ClientAccessible')
The same class is exposed by the wmic utility:
wmic shadowcopy call create Volume='C:\'
Read files that are in use
Create a snapshot of the volume, find its device name, then map it to a drive letter:
vssadmin create shadow /for=C:
vshadow -q
dosdev d: \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy1
The files in use are then readable from D:.
Restore deleted files
ShadowExplorer lets you browse existing shadow copies and restore deleted files and folders.
Notes
vssadmin create shadowis available on Windows Server editions only; on client editions use the WMI method.vshadowanddosdevare not part of a default Windows installation and must be installed separately.