From 5c564cd1406d10f22590bf7a120914282e0edd43 Mon Sep 17 00:00:00 2001 From: Ryan Holmes Date: Fri, 11 Mar 2022 13:36:31 -0500 Subject: [PATCH 1/2] Fix for #176 - If supplied a Parent VHD, we look up the database for it. Additionally, add a new parameter to generate a clone for an image ID, in case that is already known --- functions/clone/New-DcnClone.ps1 | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/functions/clone/New-DcnClone.ps1 b/functions/clone/New-DcnClone.ps1 index 65a5354..f1ee2ae 100644 --- a/functions/clone/New-DcnClone.ps1 +++ b/functions/clone/New-DcnClone.ps1 @@ -97,6 +97,8 @@ [PSCredential]$Credential, [parameter(Mandatory = $true, ParameterSetName = "ByParent")] [string]$ParentVhd, + [parameter(Mandatory = $true, ParameterSetName = "ByImage")] + [int]$ImageId, [string]$Destination, [string]$CloneName, [parameter(Mandatory = $true, ParameterSetName = "ByLatest")] @@ -131,6 +133,11 @@ Stop-PSFFunction -Message "Please enter a destination when using -SkipDatabaseMount" -Continue } + if ($ImageId) { + $result = Get-DcnImage | Where-Object ImageID -eq $ImageID + $ParentVhd = $result.ImageLocation + } + # Check the available images if (-not $ParentVhd) { $images = Get-DcnImage @@ -138,6 +145,9 @@ if ($Database -notin $images.DatabaseName) { Stop-PSFFunction -Message "There is no image for database '$Database'" -Continue } + } else { + $result = Get-DcnImage | Where-Object ImageLocation -eq $ParentVhd + $Database = $result.DatabaseName; } # Get the information store From 970c3ebbf5df5cb4532d71072923ae1aafe5651b Mon Sep 17 00:00:00 2001 From: Ryan Holmes Date: Fri, 11 Mar 2022 13:42:51 -0500 Subject: [PATCH 2/2] Add parameter documentation --- functions/clone/New-DcnClone.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/functions/clone/New-DcnClone.ps1 b/functions/clone/New-DcnClone.ps1 index f1ee2ae..a47f96e 100644 --- a/functions/clone/New-DcnClone.ps1 +++ b/functions/clone/New-DcnClone.ps1 @@ -30,6 +30,9 @@ .PARAMETER ParentVhd Points to the parent VHD to create the clone from + .PARAMETER ImageId + Image ID to create the clone from + .PARAMETER Destination Destination directory to save the clone to