Note that there are some explanatory texts on larger screens.

plurals
  1. POCreating a shadow copy using the "Backup" context in a PowerShell
    text
    copied!<p>I am in the process of writing a PowerShell script for backing up a windows computer using rsync. To this end, I am attempting to use WMI from said script to create a non-persistent Shadow copy with writer participation (as is apparently recommended for backups).</p> <p>I found out from another question (<a href="https://stackoverflow.com/questions/14207788/accessing-volume-shadow-copy-vss-snapshots-from-powershell">Accessing Volume Shadow Copy (VSS) Snapshots from powershell</a>) a way to create a shadow copy in general, but the example given there uses "ClientAccessible" as the context parameter, which result in the creation of a persistent Shadow Copy, without writer participation.</p> <p>While searching for a solution, I have found that I could use the following command to obtain a list of contexts, which I assume are understood by WMI:</p> <pre><code>Get-WmiObject win32_shadowcontext | Out-GridView </code></pre> <p>It does list have a context named "Backup", which is conveniently what I want. I proceeded to attempt creating a non-persistent shadow copy using that context:</p> <pre><code>$shadow = (Get-WmiObject -list win32_shadowcopy).Create("C:\", "Backup") </code></pre> <p>However, this seem to fail and the content of the <strong>$shadow</strong> variable is set to</p> <pre><code>ReturnValue : 5 ShadowID : {00000000-0000-0000-0000-000000000000} </code></pre> <p>According to the relevant documentation (<a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa389391(v=vs.85).aspx" rel="nofollow noreferrer">Create method of the Win32_ShadowCopy class</a>), the return value means "Unsupported shadow copy context."</p> <p>I couldn't find any relevant documentation as to why this context is unsupported or whether it is possible to use it at all. I have also tried the "FileShareBackup" and "AppRollback" contexts without success.</p> <p>I assume I am either missing something obvious, or that for some reason, WMI really doesn't support anything else than "clientAccessible" when creating shadow copies, or that this is OS dependent (I am testing this on Windows 7, 64-bit)</p> <p>How can I get this to work?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload