首页 » Troubleshoot » Mount VHD at Windows startup with PowerShell

Mount VHD at Windows startup with PowerShell

作者: lesca 分类: Troubleshoot, Tutorials, Windows 发布时间: 2017-05-29 14:02 ė浏览 432 次 6没有评论

Create a scheduled task

Command:

%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe

Parameter:

-ExecutionPolicy ByPass -file "C:\VHD\mountVHD.ps1"

Powershell Script to mount VHD

Method1: Mount-DiskImage (Recommended)

This is the recommended command to mound VHD as it does not rely on the Hyper-V role.

Mount-DiskImage -ImagePath "C:\VHD\DriveD.vhdx"

Method2: Mount-VHD

If you were using Mount-VHD to mount VHD disks like this:

Mount-VHD –Path "C:\VHD\DriveD.vhdx"

You would be possible to get this error message in future:

Mount-VHD : The Hyper-V Management Tools could not access an expected WMI class on computer 'LESCA-Computer'. This may
indicate that the Hyper-V Platform is not installed on the computer or that the version of the Hyper-V Platform is
incompatible with these management tools.

Reason:
Mount-VHD requires Hyper-V role installed

PowerShell script to mount and unlock bitlocked VHD disk

Mount-DiskImage -ImagePath "C:\VHD\DriveD.vhdx"

# In case you enabled BitLocker
$SecureString = ConvertTo-SecureString "Password" -AsPlainText -Force
Unlock-BitLocker -MountPoint "D:" -Password $SecureString

本文出自 Lesca技术宅,转载时请注明出处及相应链接。

本文永久链接: https://lesca.me/archives/mount-vhd-at-windows-startup-with-powershell.html

Leave a Reply

Your email address will not be published. Required fields are marked *

Ɣ回顶部