From b1a724fcdadfe5c90476bc54aeac00afa3a07a34 Mon Sep 17 00:00:00 2001 From: John McCall Date: Mon, 27 Jun 2022 12:07:39 -0400 Subject: [PATCH 1/2] check for psdrive before creating --- functions/clone/Invoke-DcnRepairClone.ps1 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/functions/clone/Invoke-DcnRepairClone.ps1 b/functions/clone/Invoke-DcnRepairClone.ps1 index 19dbee7..89099d5 100644 --- a/functions/clone/Invoke-DcnRepairClone.ps1 +++ b/functions/clone/Invoke-DcnRepairClone.ps1 @@ -133,7 +133,10 @@ # 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 + $drive = Get-PSDrive -Name ImagePath + if (-not $drive) { + $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 From 6336f2bb29c224336da1214e04348986d242bcec Mon Sep 17 00:00:00 2001 From: John McCall Date: Mon, 27 Jun 2022 12:23:47 -0400 Subject: [PATCH 2/2] don't fail on get-psdrive --- functions/clone/Invoke-DcnRepairClone.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/clone/Invoke-DcnRepairClone.ps1 b/functions/clone/Invoke-DcnRepairClone.ps1 index 89099d5..c6f5123 100644 --- a/functions/clone/Invoke-DcnRepairClone.ps1 +++ b/functions/clone/Invoke-DcnRepairClone.ps1 @@ -133,7 +133,7 @@ # Check if the parent of the clone can be reached try { - $drive = Get-PSDrive -Name ImagePath + $drive = Get-PSDrive -Name ImagePath -ErrorAction SilentlyContinue if (-not $drive) { $null = New-PSDrive -Name ImagePath -Root (Split-Path $image.ImageLocation) -Credential $Credential -PSProvider FileSystem }