Skip to content

Commit 32b38ec

Browse files
committed
Removed hyper-v dependency. Added -Withreplace to restore.
1 parent 3e23248 commit 32b38ec

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

functions/image/New-PSDCImage.ps1

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -300,12 +300,6 @@
300300
Stop-PSFFunction -Message "Please supply a database to create an image for" -Target $SourceSqlInstance -Continue
301301
}
302302

303-
# Check if Hyper-V is enabled
304-
if (-not (Test-PSDCHyperVEnabled -HostName $uriHost -Credential $DestinationCredential)) {
305-
Stop-PSFFunction -Message "Hyper-V is not enabled on the host." -ErrorRecord $_ -Target $uriHost
306-
return
307-
}
308-
309303
# Set time stamp
310304
$timestamp = Get-Date -format "yyyyMMddHHmmss"
311305

@@ -500,7 +494,7 @@
500494
$restore = Restore-DbaDatabase -SqlInstance $DestinationSqlInstance -SqlCredential $DestinationSqlCredential `
501495
-DatabaseName $tempDbName -Path $lastFullBackup `
502496
-DestinationDataDirectory $imageDataFolder `
503-
-DestinationLogDirectory $imageLogFolder
497+
-DestinationLogDirectory $imageLogFolder -WithReplace
504498
}
505499
catch {
506500
Stop-PSFFunction -Message "Couldn't restore database $db as $tempDbName on $DestinationSqlInstance" -Target $restore -ErrorRecord $_ -Continue
@@ -526,13 +520,13 @@
526520
# Check if computer is local
527521
if ($computer.IsLocalhost) {
528522
# Dismount the VHD
529-
$null = Dismount-VHD -Path $vhdPath
523+
$null = Dismount-DiskImage -ImagePath $vhdPath
530524

531525
# Remove the access path
532526
$null = Remove-Item -Path $accessPath -Force
533527
}
534528
else {
535-
$command = [ScriptBlock]::Create("Dismount-VHD -Path $vhdPath")
529+
$command = [ScriptBlock]::Create("Dismount-DiskImage -ImagePath $vhdPath")
536530
$null = Invoke-PSFCommand -ComputerName $computer -ScriptBlock $command -Credential $DestinationCredential
537531

538532
$command = [ScriptBlock]::Create("Remove-Item -Path $accessPath -Force")

0 commit comments

Comments
 (0)