# Implementation of creating shadow copies using Powershell

**URL:** <https://forum.rclone.org/t/implementation-of-creating-shadow-copies-using-powershell/45097>\
**Category:** Howto Guides\
**Created:** [March 17, 2024, 6:21am UTC](https://forum.rclone.org/t/implementation-of-creating-shadow-copies-using-powershell/45097 "2024-03-17T06:21:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![JerryHorace](https://forum.rclone.org/letter_avatar_proxy/v4/letter/j/977dab/32.png) [@JerryHorace](https://forum.rclone.org/u/JerryHorace)\
**Post date:** [March 17, 2024, 6:21am UTC](https://forum.rclone.org/t/implementation-of-creating-shadow-copies-using-powershell/45097/1 "2024-03-17T06:21:24Z")

</div>

I made this after referring to other posts on the forum. It feels quite simple and does not require creating symbolic links.  
(I remember seeing a post saying that you don’t have to worry about the length of the path. There is no limit, only the file/directory name has a length limit)

```auto

# Get UAC prompt
$userAccountControl = [System.Enum]::Parse([System.Security.Principal.WindowsBuiltInRole], "Administrator")
$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
$admin = $currentPrincipal.IsInRole($userAccountControl)

# If the user does not have administrator rights, prompt the user to upgrade their rights.
if (-not $admin) {
    Start-Process powershell.exe -Verb RunAs -ArgumentList ("-File", $MyInvocation.MyCommand.Path)
    exit
}

#Create volume shadow copy
$shadowCopyID = (Invoke-CimMethod -ClassName Win32_ShadowCopy -MethodName Create -Arguments @{ Volume = "C:\\" }).ShadowID
#Write-Output $shadowCopyID

$explorerPath = (Get-WmiObject -Namespace "root\CIMv2" -Class Win32_ShadowCopy | Where-Object { $_.ID -eq $shadowCopyID }).DeviceObject
#Write-Output $explorerPath

$combinedPath = $explorerPath + "\Users\Name"

rclone sync --create-empty-src-dirs --delete-excluded $combinedPath "Dest" -vv

#Delete ShadowCopy
Get-WmiObject Win32_ShadowCopy | Where-Object { $_.ID -eq $shadowCopyID } | Remove-WmiObject

Pause

```

---

<div class="post-metadata">

**Author:** ![asdffdsa](https://forum.rclone.org/letter_avatar_proxy/v4/letter/a/848f3c/32.png) [@asdffdsa](https://forum.rclone.org/u/asdffdsa)\
**Post date:** [March 17, 2024, 5:32pm UTC](https://forum.rclone.org/t/implementation-of-creating-shadow-copies-using-powershell/45097/2 "2024-03-17T17:32:15Z")

</div>

thanks for the howto.

i am the writer of another rclone+vss howto guide  
[https://forum.rclone.org/t/i-want-to-share-how-to-enable-vss-for-rclone/11644/8](https://forum.rclone.org/t/i-want-to-share-how-to-enable-vss-for-rclone/11644/8)

your script creates persistent snapshots.  
imho, much better, safer, to only use non-persistent, auto-release, no writers

---

<div class="post-metadata">

**Author:** ![system](https://forum.rclone.org/uploads/default/original/2X/3/39ad3235f6ffec76ccd0c81616bd55697b4c300d.png) [@system](https://forum.rclone.org/u/system)\
**Post date:** [April 16, 2024, 5:32pm UTC](https://forum.rclone.org/t/implementation-of-creating-shadow-copies-using-powershell/45097/3 "2024-04-16T17:32:35Z")

</div>

Closed on April 16, 2024, 5:32pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
