Share via


Create method of the Win32_ShadowCopy class

The Create method creates a shadow copy using the specified context.

This topic uses Managed Object Format (MOF) syntax. For more information about using this method, see Calling a Method.

Syntax

uint32 Create(
  [in]  string Volume,
  [in]  string Context = "ClientAccessible",
  [out] string ShadowID
);

Parameters

Volume [in]

Volume used for the shadow copy. This volume is sometimes referred to as the original volume. The Volume parameter can be specified as a volume drive letter, mount point, or volume globally unique identifier (GUID) name.

Context [in]

Context that the provider uses when creating the shadow. The default is "ClientAccessible".

ShadowID [out]

Unique identifier that identifies this shadow copy.

Return value

Return code Description
0
Success.
1
Access denied.
2
Invalid argument.
3
Specified volume not found.
4
Specified volume not supported.
5
Unsupported shadow copy context.
6
Insufficient storage.
7
Volume is in use.
8
Maximum number of shadow copies reached.
9
Another shadow copy operation is already in progress.
10
Shadow copy provider vetoed the operation.
11
Shadow copy provider not registered.
12
Shadow copy provider failure.
13
Unknown error.

Remarks

The Create method uses the same process used when manually creating a snapshot from the "Shadow Copies" dialog. If your scheduled snapshots fail, while your manual snapshots work, you can use this method to work around that issue.

Examples

The following Jscript sample takes a snapshot of a volume that's already been configured with a VSS storage volume.

var Win32_ShadowCopy = GetObject("winmgmts:\\\\.\\root\\cimv2:Win32_ShadowCopy");

Win32_ShadowCopy.Create(
  "C:\\",
  "ClientAccessible"
);

The following PowerShell code creates a shadow copy.

# get existing shadow copies
$shadow = get-wmiobject win32_shadowcopy
"There are {0} shadow copies on this sytem" -f $shadow.count
""

# get static method
$class=[WMICLASS]"root\cimv2:win32_shadowcopy"

# create a new shadow copy
"Creating a new shadow copy"
$class.create("C:\", "ClientAccessible")

# Count again
$shadow = get-wmiobject win32_shadowcopy
"There are now {0} shadow copies on this sytem" -f $shadow.count

The previous code sample returns the following information:

There are 8 shadow copies on this sytem

Creating a new shadow copy
  
__GENUS          : 2
__CLASS          : __PARAMETERS
__SUPERCLASS     :
__DYNASTY        : __PARAMETERS
__RELPATH        :
__PROPERTY_COUNT : 2
__DERIVATION     : {}
__SERVER         :
__NAMESPACE      :
__PATH           :
ReturnValue      : 0
ShadowID         : {18BDD207-FB1B-4860-B918-B94C9EBF1F1F}

There are now 9 shadow copies on this sytem

Requirements

Minimum supported client
None supported
Minimum supported server
Windows Server 2003
Namespace
Root\CIMV2
MOF
Vss.mof
DLL
Vsswmi.dll

See also

Win32_ShadowCopy