Last active
September 24, 2022 07:21
-
-
Save cyanide-burnout/bfd0a93634e5c884578eef9249094851 to your computer and use it in GitHub Desktop.
Create a shadow copy of disk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$drive = "F:" | |
# Create and mount shadow copy | |
$snapshot = (Get-WmiObject -List Win32_ShadowCopy).Create("$drive\\", "ClientAccessible") | |
$copy = Get-WmiObject Win32_ShadowCopy | Where-Object { $_.ID -eq $snapshot.ShadowID } | |
cmd /C mklink /d $drive\ShadowCopy "$($copy.DeviceObject)\\" | |
# Unmount and remove shadow copy | |
cmd /c rmdir $drive\ShadowCopy | |
$copy.Delete() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment