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: Can't create path if root drive #189

Closed
4 tasks done
lowlydba opened this issue Apr 19, 2022 · 0 comments · Fixed by #190
Closed
4 tasks done

New-DcnClone: Can't create path if root drive #189

lowlydba opened this issue Apr 19, 2022 · 0 comments · Fixed by #190

Comments

@lowlydba
Copy link
Contributor

Before submitting the bug

  • Ensure you are able to reproduce it on the latest released version (we release often)
  • Verified this bug is not already reported in an issue
  • Verified errors are not related to permissions
  • Can reproduce in a clean PowerShell session (clean = powershell -NoProfile)

Describe the bug
When the destination for a clone is a root directory, the trailing \ is removed and it creates a folder by the name instead of the file, making it unable to work

This was introduced when Join-Path was removed since Combine won't add it back automagically:

# Remove the last "\" from the path it would mess up the mount of the VHD
if ($Destination.EndsWith("\")) {
$Destination = $Destination.Substring(0, $Destination.Length - 1)
}

$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
}
}

To Reproduce
Steps to reproduce the behavior:

New-DcnClone -Destination "C:\" ...

Expected behavior
The clone is created at C:\, not attempted at C:

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

Successfully merging a pull request may close this issue.

1 participant