Skip to content

Commit 5795aba

Browse files
committed
Changed functionality from Hyper-V to disk part/native
1 parent 3e5c628 commit 5795aba

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

functions/disk/Initialize-PSDCVhdDisk.ps1

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,20 @@
8787
Write-PSFMessage -Message "Vhd is already mounted" -Level Warning
8888

8989
# retrieve the specific disk
90-
$disk = $disks | Where-Object {$_.Location -eq $Path}
90+
$disk = $disks | Where-Object Location -eq $Path
9191
}
9292
else {
93-
if ($PSCmdlet.ShouldProcess($disk, "Mounting disk")) {
93+
if ($PSCmdlet.ShouldProcess("Mounting disk")) {
9494
# Mount the vhd
9595
try {
9696
Write-PSFMessage -Message "Mounting disk $disk" -Level Verbose
9797

98-
$disk = Mount-VHD -Path $Path -PassThru | Get-Disk
98+
#$disk = Mount-VHD -Path $Path -PassThru | Get-Disk
99+
# Mount the disk
100+
Mount-DiskImage -ImagePath $Path
101+
102+
# Get the disk
103+
$disk = Get-Disk | Where-Object Location -eq $Path
99104
}
100105
catch {
101106
Stop-PSFFunction -Message "Couldn't mount vhd" -Target $Path -ErrorRecord $_ -Continue
@@ -123,7 +128,8 @@
123128
}
124129
catch {
125130
# Dismount the drive
126-
Dismount-VHD -Path $Path
131+
#Dismount-VHD -Path $Path
132+
Dismount-DiskImage -DiskImage $Path
127133

128134
Stop-PSFFunction -Message "Couldn't create the partition" -Target $disk -ErrorRecord $_ -Continue
129135
}

0 commit comments

Comments
 (0)