Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
lowlydba opened this issue May 17, 2022 · 1 comment
Open

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

lowlydba opened this issue May 17, 2022 · 1 comment

Comments

@lowlydba
Copy link
Contributor

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.

@lowlydba
Copy link
Contributor Author

I can make a PR if this is an acceptable change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant