Skip to content

Instantly share code, notes, and snippets.

@cyanide-burnout
Last active September 24, 2022 07:21
Show Gist options
  • Save cyanide-burnout/bfd0a93634e5c884578eef9249094851 to your computer and use it in GitHub Desktop.
Save cyanide-burnout/bfd0a93634e5c884578eef9249094851 to your computer and use it in GitHub Desktop.
Create a shadow copy of disk
$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