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

Issue the same commands for creating and mounting the image regardles… #151

Merged
merged 1 commit into from
Jan 8, 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
22 changes: 9 additions & 13 deletions functions/clone/New-DcnClone.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -401,23 +401,19 @@
try {
Write-PSFMessage -Message "Creating clone from $ParentVhd" -Level Verbose

$command = "create vdisk file='$($clonePath)' parent='$ParentVhd'"

$command = [ScriptBlock]::Create("
`$command = `"create vdisk file='$($clonePath)' parent='$ParentVhd'`"
Set-Content -Path './diskpart.txt' -Value `$command -Force
diskpart /s './diskpart.txt'
")

# Check if computer is local
if ($computer.IsLocalhost) {
# Set the content of the diskpart script file
Set-Content -Path $diskpartScriptFile -Value $command -Force

$script = [ScriptBlock]::Create("diskpart /s $diskpartScriptFile")
$null = Invoke-PSFCommand -ScriptBlock $script
$null = Invoke-PSFCommand -ScriptBlock $command
}
else {
$command = [ScriptBlock]::Create("New-VHD -ParentPath $ParentVhd -Path `"$($clonePath)`" -Differencing")
$vhd = Invoke-PSFCommand -ComputerName $computer -ScriptBlock $command -Credential $Credential

if (-not $vhd) {
return
}
$null = Invoke-PSFCommand -ComputerName $computer -ScriptBlock $command -Credential $Credential
}

}
Expand Down Expand Up @@ -448,7 +444,7 @@
# Get the disk based on the name of the vhd
$command = [ScriptBlock]::Create("
`$diskImage = Get-DiskImage -ImagePath $($clonePath)
Get-Disk | Where-Object Number -eq $($diskImage.Number)
Get-Disk | Where-Object Number -eq `$(`$diskImage.Number)
")
$disk = Invoke-PSFCommand -ComputerName $computer -ScriptBlock $command -Credential $Credential
}
Expand Down