You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
743 B
PowerShell
19 lines
743 B
PowerShell
if ($args.Length -eq 0) {
|
|
$kopiaSnapshotId = $env:KOPIA_SNAPSHOT_ID
|
|
} else {
|
|
$kopiaSnapshotId = $args[0]
|
|
}
|
|
|
|
if (([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
|
|
$mountPoint = Get-Item "${PSScriptRoot}\${kopiaSnapshotId}"
|
|
$mountedVolume = $mountPoint.Target
|
|
|
|
cmd /c rmdir $mountPoint
|
|
Get-CimInstance -ClassName Win32_ShadowCopy | Where-Object { "$($_.DeviceObject)\" -eq "\\?\${mountedVolume}" } | Remove-CimInstance
|
|
} else {
|
|
Start-Process 'powershell' '-f', $MyInvocation.MyCommand.Path, $kopiaSnapshotId -Verb RunAs -WindowStyle Hidden -Wait
|
|
if ($proc.ExitCode) {
|
|
exit $proc.ExitCode
|
|
}
|
|
}
|