Skip to content

New-DcnClone: -Force should remove existing clone files #206

@lowlydba

Description

@lowlydba

Is your feature request related to a problem? Please describe.
I'm encountering issues where occasionally the clone files can't be created due to being locked by other processes (why is still TBD). This leaves orphaned files and no metadata entry for the clone. The next time I try to create the clone again, the function stops due to these checks:

# Check if the clone vhd does not yet exist
$clonePath = [System.IO.Path]::Combine($Destination, "$($CloneName).vhdx")
if ($computer.IsLocalhost) {
if (Test-Path -Path $clonePath) {
Stop-PSFFunction -Message "Clone $CloneName already exists" -Target $accessPath -Continue
}
}
else {
$command = [ScriptBlock]::Create("Test-Path -Path `"$($clonePath)`"")
$result = Invoke-PSFCommand -ComputerName $computer -ScriptBlock $command -Credential $Credential
if ($result) {
Stop-PSFFunction -Message "Clone $CloneName already exists" -Target $accessPath -Continue
}
}

If using the -Force flag, it would be nice if these could be removed automatically instead of exiting, so that I don't have to write my own orphan file handling process outside of the function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions