Accessing Volume Shadow Copy (VSS) Snapshots from powershell

前端 未结 4 450
一向
一向 2020-12-08 02:54

I am attempting to create and access a Volume Shadow Copy snapshot using the Windows Power Shell in Windows 7. I found that I can create snapshots using the following via a

4条回答
  •  感情败类
    2020-12-08 03:48

    How did you create the symlink? As outlined in that article, you have to specify the device path with a trailing backslash:

    $s1 = (Get-WmiObject -List Win32_ShadowCopy).Create("C:\", "ClientAccessible")
    $s2 = Get-WmiObject Win32_ShadowCopy | Where-Object { $_.ID -eq $s1.ShadowID }
    
    $d  = $s2.DeviceObject + "\"   # <-- this here
    
    cmd /c mklink /d C:\shadowcopy "$d"
    

    After this, I was able to access the shadow copy mounted to C:\shadowcopy just fine.

    To unmount the shadow copy call $s2.Delete(), as @KeyszerS pointed out in the comments.

提交回复
热议问题