Win32_ShadowCopy

The Win32_ShadowCopy class is a storage extent that represents a duplicate copy of the original volume at a previous time.

The Win32_ShadowCopy class is a storage extent that represents a duplicate copy of the original volume at a previous time.

Methods

Win32_ShadowCopy has 1 methods:
Method Description
Create Creates a shadow copy by using the specified context.

Learn more about Invoke-CimMethod and how to invoke commands. Click any of the methods listed above to learn more about their purpose, parameters, and return value.

Properties

Win32_ShadowCopy returns 27 properties:

'Caption','ClientAccessible','Count','Description','DeviceObject','Differential',
'ExposedLocally','ExposedName','ExposedRemotely','HardwareAssisted','ID','Imported','InstallDate',
'Name','NoAutoRelease','NotSurfaced','NoWriters','OriginatingMachine','Persistent','Plex',
'ProviderID','ServiceMachine','SetID','State','Status','Transportable','VolumeName'

Unless explicitly marked as writeable, all properties are read-only. Read all properties for all instances:

Get-CimInstance -ClassName Win32_ShadowCopy -Property *

Most WMI classes return one or more instances.

When Get-CimInstance returns no result, then apparently no instances of class Win32_ShadowCopy exist. This is normal behavior.

Either the class is not implemented on your system (may be deprecated or due to missing drivers, i.e. CIM_VideoControllerResolution), or there are simply no physical representations of this class currently available (i.e. Win32_TapeDrive).

Caption

STRING

Get-CimInstance -ClassName Win32_ShadowCopy | Select-Object -Property Caption

ClientAccessible

BOOLEAN

If true, the shadow copy is created by the Windows Previous Versions component.

Get-CimInstance -ClassName Win32_ShadowCopy | Select-Object -Property ClientAccessible

Count

UINT32

Number of shadow copies in a shadow copy set to which a shadow copy belongs.

Get-CimInstance -ClassName Win32_ShadowCopy | Select-Object -Property Count

Description

STRING

Get-CimInstance -ClassName Win32_ShadowCopy | Select-Object -Property Description

DeviceObject

STRING

Windows object manager name for an underlying storage device that supports the original volume.

Get-CimInstance -ClassName Win32_ShadowCopy | Select-Object -Property DeviceObject

Differential

BOOLEAN

If true, the shadow copy is created by a differential shadow copy provider. The provider can be implemented in hardware or software.

Get-CimInstance -ClassName Win32_ShadowCopy | Select-Object -Property Differential

ExposedLocally

BOOLEAN

If true, the shadow copy is exposed on the local computer with a drive letter or mount point. If ExposedLocally and ExposedRemotely are not set, the shadow copy is hidden.

Get-CimInstance -ClassName Win32_ShadowCopy | Select-Object -Property ExposedLocally

ExposedName

STRING

File system name of a shadow copy when it is exposed. The ExposedName property might contain a drive letter or mount point. The ExposedName property is NULL when a shadow copy is hidden or otherwise not exposed.

Get-CimInstance -ClassName Win32_ShadowCopy | Select-Object -Property ExposedName

ExposedRemotely

BOOLEAN

If true, the shadow copy is exposed on a remote computer with a network share. If ExposedRemotely and ExposedLocally are not set, the shadow copy is hidden.

Get-CimInstance -ClassName Win32_ShadowCopy | Select-Object -Property ExposedRemotely

HardwareAssisted

BOOLEAN

If true, the shadow copy is created by a hardware shadow copy provider.

Get-CimInstance -ClassName Win32_ShadowCopy | Select-Object -Property HardwareAssisted

ID

STRING

Unique identifier for a shadow copy on the system.

Get-CimInstance -ClassName Win32_ShadowCopy | Select-Object -Property ID

Imported

BOOLEAN

If true, the shadow copy is imported to a computer by using the Import method and is not created by using the Create method.

Get-CimInstance -ClassName Win32_ShadowCopy | Select-Object -Property Imported

InstallDate

DATETIME

Get-CimInstance -ClassName Win32_ShadowCopy | Select-Object -Property InstallDate

Name

STRING

Get-CimInstance -ClassName Win32_ShadowCopy | Select-Object -Property Name

NoAutoRelease

BOOLEAN

If true, the shadow copy is retained after the requestor process ends. If false, the shadow copy is automatically deleted when the requestor process ends.

Get-CimInstance -ClassName Win32_ShadowCopy | Select-Object -Property NoAutoRelease

NotSurfaced

BOOLEAN

If true, the shadow copy is not currently in the device namespace of a local computer.

Get-CimInstance -ClassName Win32_ShadowCopy | Select-Object -Property NotSurfaced

NoWriters

BOOLEAN

If true, the shadow copy is created with the involvement of the shadow copy writer components.

Get-CimInstance -ClassName Win32_ShadowCopy | Select-Object -Property NoWriters

OriginatingMachine

STRING

Name of the computer that hosts the original volume.

Get-CimInstance -ClassName Win32_ShadowCopy | Select-Object -Property OriginatingMachine

Persistent

BOOLEAN

If true, the shadow copy is persistent across reboots.

Get-CimInstance -ClassName Win32_ShadowCopy | Select-Object -Property Persistent

Plex

BOOLEAN

If true, the shadow copy is created by a split mirror shadow copy provider. The provider can be implemented in hardware or software.

Get-CimInstance -ClassName Win32_ShadowCopy | Select-Object -Property Plex

ProviderID

STRING

Unique identifier for a shadow provider that creates a shadow.

Get-CimInstance -ClassName Win32_ShadowCopy | Select-Object -Property ProviderID

ServiceMachine

STRING

Name of the computer that services the shadow copy.

Get-CimInstance -ClassName Win32_ShadowCopy | Select-Object -Property ServiceMachine

SetID

STRING

Unique identifier for a shadow copy set to which the shadow belongs.

Get-CimInstance -ClassName Win32_ShadowCopy | Select-Object -Property SetID

State

UINT32

Current state of a shadow copy.

State returns a numeric value. To translate it into a meaningful text, use any of the following approaches:

Use a PowerShell Hashtable
$State_map = @{
Unknown = '0'
Preparing = '1'
ProcessingPrepare = '2'
Prepared = '3'
ProcessingPrecommit = '4'
Precommitted = '5'
ProcessingCommit = '6'
Committed = '7'
ProcessingPostcommit = '8'
Created = '9'
Aborted = '10'
Deleted = '11'
  Count = '12'
}
Use a switch statement
switch([int]$value)
{
  Unknown    {'0'}
  Preparing  {'1'}
  ProcessingPrepare {'2'}
  Prepared   {'3'}
  ProcessingPrecommit {'4'}
  Precommitted {'5'}
  ProcessingCommit {'6'}
  Committed  {'7'}
  ProcessingPostcommit {'8'}
  Created    {'9'}
  Aborted    {'10'}
  Deleted    {'11'}
  Count      {'12'}
  default    {"$value"}
}
Use Enum structure
Enum EnumState
{
  _0    = Unknown
  _1    = Preparing
  _2    = ProcessingPrepare
  _3    = Prepared
  _4    = ProcessingPrecommit
  _5    = Precommitted
  _6    = ProcessingCommit
  _7    = Committed
  _8    = ProcessingPostcommit
  _9    = Created
  _10   = Aborted
  _11   = Deleted
  _12   = Count
}

Examples

Use $State_map in a calculated property for Select-Object
<# 
  this example uses a hashtable to translate raw numeric values for 
  property "State" to friendly text

  Note: to use other properties than "State", look up the appropriate 
  translation hashtable for the property you would like to use instead.
#>

#region define hashtable to translate raw values to friendly text

# Please note: this hashtable is specific for property "State" 
# to translate other properties, use their translation table instead
$State_map = @{
Unknown = '0'
Preparing = '1'
ProcessingPrepare = '2'
Prepared = '3'
ProcessingPrecommit = '4'
Precommitted = '5'
ProcessingCommit = '6'
Committed = '7'
ProcessingPostcommit = '8'
Created = '9'
Aborted = '10'
Deleted = '11'
  Count = '12'
}

#endregion define hashtable

#region define calculated property (to be used with Select-Object)

<#
  a calculated property is defined by a hashtable with keys "Name" and "Expression"
  "Name" defines the name of the property (in this example, it is "State", but you can rename it to anything else)
  "Expression" defines a scriptblock that calculates the content of this property
  in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
  value to its friendly text counterpart:
#>
 
$State = @{
  Name = 'State'
  Expression = {
    # property is an array, so process all values
    $value = $_.State
    $State_map[[int]$value]
  }  
}
#endregion define calculated property

# retrieve the instances, and output the properties "Caption" and "State". The latter
# is defined by the hashtable in $State: 
Get-CimInstance -Class Win32_ShadowCopy | Select-Object -Property Caption, $State

# ...or dump content of property State:
$friendlyValues = Get-CimInstance -Class Win32_ShadowCopy | 
    Select-Object -Property $State |
    Select-Object -ExpandProperty State

# output values
$friendlyValues

# output values as comma separated list
$friendlyValues -join ', '

# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use $State_map to directly translate raw values from an instance
<# 
  this example uses a hashtable to manually translate raw numeric values 
  for property "Win32_ShadowCopy" to friendly text. This approach is ideal when
  there is just one instance to work with.

  Note: to use other properties than "Win32_ShadowCopy", look up the appropriate 
  translation hashtable for the property you would like to use instead.
#>

#region define hashtable to translate raw values to friendly text

# Please note: this hashtable is specific for property "Win32_ShadowCopy" 
# to translate other properties, use their translation table instead
$State_map = @{
Unknown = '0'
Preparing = '1'
ProcessingPrepare = '2'
Prepared = '3'
ProcessingPrecommit = '4'
Precommitted = '5'
ProcessingCommit = '6'
Committed = '7'
ProcessingPostcommit = '8'
Created = '9'
Aborted = '10'
Deleted = '11'
  Count = '12'
}

#endregion define hashtable

# get one instance:
$instance = Get-CimInstance -Class Win32_ShadowCopy | Select-Object -First 1

<#
  IMPORTANT: this example processes only one instance to illustrate
  the number-to-text translation. To process all instances, replace
  "Select-Object -First 1" with a "Foreach-Object" loop, and use
  the iterator variable $_ instead of $instance
#>

# query the property
$rawValue = $instance.State  

# translate raw value to friendly text:
$friendlyName = $State_map[[int]$rawValue]

# output value
$friendlyName
Use a switch statement inside a calculated property for Select-Object
<# 
  this example uses a switch clause to translate raw numeric 
  values for property "State" to friendly text. The switch
  clause is embedded into a calculated property so there is
  no need to refer to external variables for translation.

  Note: to use other properties than "State", look up the appropriate 
  translation switch clause for the property you would like to use instead.
#>

#region define calculated property (to be used with Select-Object)

<#
  a calculated property is defined by a hashtable with keys "Name" and "Expression"
  "Name" defines the name of the property (in this example, it is "State", but you can rename it to anything else)
  "Expression" defines a scriptblock that calculates the content of this property
  in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
  value to its friendly text counterpart:
#>
 
$State = @{
  Name = 'State'
  Expression = {
    # property is an array, so process all values
    $value = $_.State
    
    switch([int]$value)
      {
        Unknown    {'0'}
        Preparing  {'1'}
        ProcessingPrepare {'2'}
        Prepared   {'3'}
        ProcessingPrecommit {'4'}
        Precommitted {'5'}
        ProcessingCommit {'6'}
        Committed  {'7'}
        ProcessingPostcommit {'8'}
        Created    {'9'}
        Aborted    {'10'}
        Deleted    {'11'}
        Count      {'12'}
        default    {"$value"}
      }
      
  }  
}
#endregion define calculated property

# retrieve all instances...
Get-CimInstance -ClassName Win32_ShadowCopy | 
  # ...and output properties "Caption" and "State". The latter is defined
  # by the hashtable in $State:
  Select-Object -Property Caption, $State
Use the Enum from above to auto-translate the code values
<# 
  this example translates raw values by means of type conversion
  the friendly names are defined as enumeration using the
  keyword "enum" (PowerShell 5 or better)
  
  The raw value(s) are translated to friendly text by 
  simply converting them into the enum type.
  
  Note: to use other properties than "Win32_ShadowCopy", look up the appropriate 
  enum definition for the property you would like to use instead.
#>


#region define enum with value-to-text translation:
Enum EnumState
{
  _0    = Unknown
  _1    = Preparing
  _2    = ProcessingPrepare
  _3    = Prepared
  _4    = ProcessingPrecommit
  _5    = Precommitted
  _6    = ProcessingCommit
  _7    = Committed
  _8    = ProcessingPostcommit
  _9    = Created
  _10   = Aborted
  _11   = Deleted
  _12   = Count
}

#endregion define enum

# get one instance:
$instance = Get-CimInstance -Class Win32_ShadowCopy | Select-Object -First 1

<#
  IMPORTANT: this example processes only one instance to focus on
  the number-to-text type conversion. 
  
  To process all instances, replace   "Select-Object -First 1" 
  with a "Foreach-Object" loop, and use the iterator variable 
  $_ instead of $instance
#>

# query the property:
$rawValue = $instance.State

#region using strict type conversion

<#
  Note: strict type conversion fails if the raw value is 
  not defined by the enum. So if the list of allowable values
  was extended and the enum does not match the value,
  an exception is thrown
#>

# convert the property to the enum **State** 
[EnumState]$rawValue 

# get a comma-separated string:
[EnumState]$rawValue -join ',' 
#endregion

#region using operator "-as"

<#
  Note: the operator "-as" accepts values not defined
  by the enum and returns $null instead of throwing
  an exception
#>

$rawValue -as [EnumState]
#endregion

Enums must cover all possible values. If State returns a value that is not defined in the enum, an exception occurs. The exception reports the value that was missing in the enum. To fix, add the missing value to the enum.

Status

STRING

Current status of an object. Various operational and nonoperational statuses can be defined. Available values:

$values = 'Degraded','Error','Lost Comm','No Contact','NonRecover','OK','Pred Fail','Service','Starting','Stopping','Stressed','Unknown'
Get-CimInstance -ClassName Win32_ShadowCopy | Select-Object -Property Status

Transportable

BOOLEAN

If true, the shadow copy can be surfaced on another computer. If false, and the volumes are surfaced locally, it may not be possible to surface them later on a different computer.

Get-CimInstance -ClassName Win32_ShadowCopy | Select-Object -Property Transportable

VolumeName

STRING

Name of the original volume for which a shadow copy is made.

Get-CimInstance -ClassName Win32_ShadowCopy | Select-Object -Property VolumeName

Examples

List all instances of Win32_ShadowCopy
Get-CimInstance -ClassName Win32_ShadowCopy

Learn more about Get-CimInstance and the deprecated Get-WmiObject.

View all properties
Get-CimInstance -ClassName Win32_ShadowCopy -Property *
View key properties only
Get-CimInstance -ClassName Win32_ShadowCopy -KeyOnly

Selecting Properties

To select only some properties, pipe the results to Select-Object -Property a,b,c with a comma-separated list of the properties you require. Wildcards are permitted.

Get-CimInstance always returns all properties but only retrieves the ones that you specify. All other properties are empty but still present. That’s why you need to pipe the results into Select-Object if you want to limit the visible properties, i.e. for reporting.

Selecting Properties

The code below lists all available properties. Remove the ones you do not need:

$properties = 'Caption',
              'ClientAccessible',
              'Count',
              'Description',
              'DeviceObject',
              'Differential',
              'ExposedLocally',
              'ExposedName',
              'ExposedRemotely',
              'HardwareAssisted',
              'ID',
              'Imported',
              'InstallDate',
              'Name',
              'NoAutoRelease',
              'NotSurfaced',
              'NoWriters',
              'OriginatingMachine',
              'Persistent',
              'Plex',
              'ProviderID',
              'ServiceMachine',
              'SetID',
              'State',
              'Status',
              'Transportable',
              'VolumeName'
Get-CimInstance -ClassName Win32_ShadowCopy | Select-Object -Property $properties
Limiting Network Bandwidth

If you work remotely, it makes sense to limit network bandwidth by filtering the properties on the server side, too:

Get-CimInstance -Class Win32_ShadowCopy -Property $property | 
Select-Object -Property $property

Selecting Instances

To select some instances, use Get-CimInstance and a WMI Query. The wildcard character in WMI Queries is % (and not “*”).

The parameter -Filter runs a simple query.

Listing all instances where the property Caption starts with “A”
Get-CimInstance -Class Win32_ShadowCopy -Filter 'Caption LIKE "a%"' 
Using a WQL Query

The parameter -Query uses a query similar to SQL and combines the parameters -Filter and -Property. This returns all instances where the property Caption starts with “A”, and returns the properties specified:

Get-CimInstance -Query "SELECT ClientAccessible, Plex, Imported, ExposedRemotely FROM Win32_ShadowCopy WHERE Caption LIKE 'a%'"

Any property you did not specify is still present but empty. You might need to use Select-Object to remove all unwanted properties:

Get-CimInstance -Query "SELECT ClientAccessible, Plex, Imported, ExposedRemotely FROM Win32_ShadowCopy WHERE Caption LIKE 'a%'" | Select-Object -Property ClientAccessible, Plex, Imported, ExposedRemotely

Accessing Remote Computers

To access remote systems, you need to have proper permissions. User the parameter -ComputerName to access one or more remote systems.

Authenticating as Current User
# one or more computer names or IP addresses:
$list = 'server1', 'server2'

# authenticate with your current identity:
$result = Get-CimInstance -ClassName Win32_ShadowCopy -ComputerName $list 
$result
Authenticating as Different User

Use a CIMSession object to authenticate with a new identity:

# one or more computer names or IP addresses:
$list = 'server1', 'server2'

# authenticate with a different identity:
$cred = Get-Credential -Message 'Authenticate to retrieve WMI information:'
$session = New-CimSession -ComputerName $list -Credential $cred

$result = Get-CimInstance Win32_ShadowCopy -CimSession $session

# remove the session after use (if you do not plan to re-use it later)
Remove-CimSession -CimSession $session

$result

Learn more about accessing remote computers.

Requirements

To use Win32_ShadowCopy, the following requirements apply:

PowerShell

Get-CimInstance was introduced with PowerShell Version 3.0, which in turn was introduced on clients with Windows 8 and on servers with Windows Server 2012.

If necessary, update Windows PowerShell to Windows PowerShell 5.1, or install PowerShell 7 side-by-side.

Operating System

Win32_ShadowCopy was introduced on clients with None supported and on servers with Windows Server 2003.

Namespace

Win32_ShadowCopy lives in the Namespace Root/CIMV2. This is the default namespace. There is no need to use the -Namespace parameter in Get-CimInstance.

Implementation

Win32_ShadowCopy is implemented in Vsswmi.dll and defined in Vss.mof. Both files are located in the folder C:\Windows\system32\wbem:

explorer $env:windir\system32\wbem
notepad $env:windir\system32\wbem\Vss.mof