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

Invoke-DcnRepairClone errors when PSDrive exists #212

Closed
4 tasks done
lowlydba opened this issue Jun 27, 2022 · 0 comments · Fixed by #213
Closed
4 tasks done

Invoke-DcnRepairClone errors when PSDrive exists #212

lowlydba opened this issue Jun 27, 2022 · 0 comments · Fixed by #213

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 running Invoke-DcnRepairClone, the section that validates the PSDrive errors out if the drive already exists since the New-PSDrive command doesn't gracefully handle existing drives. It should check for the drive before attempting to create it.

# Check if the parent of the clone can be reached
try {
$null = New-PSDrive -Name ImagePath -Root (Split-Path $image.ImageLocation) -Credential $Credential -PSProvider FileSystem
}
catch {
Stop-PSFFunction -Message "Could not create drive for image path '$($image.ImageLocation)'" -ErrorRecord $_ -Continue
}

To Reproduce
Steps to reproduce the behavior:

Invoke-DcnRepairClone -HostName MyHostName

results in:

New-PSDrive : A drive with the name 'ImagePath' already exists.
At line:136 char:29
+ ...     $null = New-PSDrive -Name ImagePath -Root (Split-Path $image.Imag ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceExists: (ImagePath:String) [New-PSDrive], SessionStateException
    + FullyQualifiedErrorId : DriveAlreadyExists,Microsoft.PowerShell.Commands.NewPSDriveCommand

Expected behavior
No more errors in my life 🎵

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