title: Creating a shadow copy using the "Backup" context in a PowerShell
body: <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 results 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 the 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 seems 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="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>