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

Fix for Issue 176 #177

Merged
merged 3 commits into from
Mar 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions functions/clone/New-DcnClone.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -97,6 +100,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")]
Expand Down Expand Up @@ -131,13 +136,21 @@
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

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
Expand Down