Hello,
On a usb drive, I have a VHDx file (which is bitlocked).
I want to create two scripts to quickly mount and dismount the VHDx file on Windows 8 system.
I want to mount the drive in a subfolder on my usb disk.
I succeed in writing the mount script:
$scriptDir = Split-Path($MyInvocation.MyCommand.Definition)
$vhdPath = Join-Path $scriptDir "\_private\crypted.vhdx"
$mountPath = Join-Path $scriptDir "\Data"
if(-not (Get-ChildItem $mountPath -Force)) # check if not already mounted
{
Mount-VHD -NoDriveLetter -Path $mountPath
}
else{
Write-Warning "Already mounted"
}
However, the dismount script does not works:
$scriptDir = Split-Path($MyInvocation.MyCommand.Definition)
$vhdPath = Join-Path $scriptDir "\_private\crypted.vhdx"
$mountPath = Join-Path $scriptDir "\Data"
if(Get-ChildItem $mountPath) # check if not already mounted
{
Dismount-VHD -Path $vhdPath
}
else{
Write-Warning "Not mounted"
}
The Dismount-VHD
-Path $vhdPath
throw an error :
Dismount-VHD : lment N:_private\crypted.vhdx introuvable.
(can be translated to something like item
N:\_private\crypted.vhdx cannot be found
)
I also try with Dismount-VHD
-Path $mountPath
, but I get another exception:
Dismount-VHD : Le paramtre nest pas valide. N:\Data nest pas un fichier de disque dur virtuel existant.
(translation: Invalid parameter: n:\Data is not a disk file)
What is the correct way to dismount a VHD file?
Thanks,