Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PowerShell:使用DiscUtils创建并初始化虚拟磁盘_Powershell_Virtual Machine_Diskimage - Fatal编程技术网

PowerShell:使用DiscUtils创建并初始化虚拟磁盘

PowerShell:使用DiscUtils创建并初始化虚拟磁盘,powershell,virtual-machine,diskimage,Powershell,Virtual Machine,Diskimage,使用时,我得到以下错误: Import-Module DiscUtils.psd1 New-VirtualDisk hd.vhd -Type VHD-dynamic -Size 500MB Initialize-VirtualDisk hd.vhd -VolumeManager Bios Initialize-VirtualDisk : Path specified is not a virtual disk hd.vhd有效,如果使用其他工具装载,则Windows磁盘管理会识别 刚刚找到了

使用时,我得到以下错误:

Import-Module DiscUtils.psd1
New-VirtualDisk hd.vhd -Type VHD-dynamic -Size 500MB
Initialize-VirtualDisk hd.vhd -VolumeManager Bios

Initialize-VirtualDisk : Path specified is not a virtual disk

hd.vhd
有效,如果使用其他工具装载,则Windows磁盘管理会识别

刚刚找到了正确的方法:

Import-Module DiscUtils.psd1
New-VirtualDisk hd.vhd -Type VHD-dynamic -Size 500MB
New-PSDrive vhd -PSProvider virtualdisk -Root hd.vhd -ReadWrite
Initialize-VirtualDisk vhd: -VolumeManager Bios
随后可以对驱动器进行分区和格式化。
要格式化前250MB NTFS,请执行以下操作:

New-Volume vhd: -Size 250MB -Type WindowsNtfs
Format-Volume vhd:\Volume0 -Filesystem Ntfs -Label "virtdrive"