Skip to content

Instantly share code, notes, and snippets.

@ojgarciab
Created June 16, 2023 12:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ojgarciab/4528eb83f85d152def94fdff8db0ffd0 to your computer and use it in GitHub Desktop.
Save ojgarciab/4528eb83f85d152def94fdff8db0ffd0 to your computer and use it in GitHub Desktop.
Crear y usar copias "shadow" para acceder a archivos en uso
# Documentación:
# https://learn.microsoft.com/en-us/previous-versions/windows/desktop/legacy/aa394428(v=vs.85)
# Creamos la copia
$shadow = (Get-WmiObject -List Win32_ShadowCopy).Create("C:\\", "ClientAccessible")
$shadow2 = Get-WmiObject Win32_ShadowCopy | Where-Object { $_.ID -eq $shadow.ShadowID }
$dispositivo = $shadow2.DeviceObject + "\\"
cmd /c mklink /d C:\shadowcopy "$dispositivo"
# Acceso a los datos desde C:\shadowcopy
# ...
# Borramos la copia
Remove-Item c:\shadowcopy -Confirm:$false -Force
$dispositivo.Delete()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment