New-VHD
Creates one or more new virtual hard disks.
语法
Parameter Set: DynamicWithoutSource
New-VHD [-Path] <String[]> [-SizeBytes] <UInt64> [-AsJob] [-BlockSizeBytes <UInt32> ] [-CimSession <Microsoft.Management.Infrastructure.CimSession[]> ] [-ComputerName <String[]> ] [-Credential <System.Management.Automation.PSCredential[]> ] [-Dynamic] [-LogicalSectorSizeBytes <UInt32> {512 | 4096} ] [-PhysicalSectorSizeBytes <UInt32> {512 | 4096} ] [-Confirm] [-WhatIf] [ <CommonParameters>]
Parameter Set: Differencing
New-VHD [-Path] <String[]> [-ParentPath] <String> [[-SizeBytes] <UInt64> ] [-AsJob] [-BlockSizeBytes <UInt32> ] [-CimSession <Microsoft.Management.Infrastructure.CimSession[]> ] [-ComputerName <String[]> ] [-Credential <System.Management.Automation.PSCredential[]> ] [-Differencing] [-PhysicalSectorSizeBytes <UInt32> {512 | 4096} ] [-Confirm] [-WhatIf] [ <CommonParameters>]
Parameter Set: DynamicWithSource
New-VHD [-Path] <String[]> -Dynamic -SourceDisk <UInt32> [-AsJob] [-BlockSizeBytes <UInt32> ] [-CimSession <Microsoft.Management.Infrastructure.CimSession[]> ] [-ComputerName <String[]> ] [-Credential <System.Management.Automation.PSCredential[]> ] [-Confirm] [-WhatIf] [ <CommonParameters>]
Parameter Set: FixedWithoutSource
New-VHD [-Path] <String[]> [-SizeBytes] <UInt64> -Fixed [-AsJob] [-BlockSizeBytes <UInt32> ] [-CimSession <Microsoft.Management.Infrastructure.CimSession[]> ] [-ComputerName <String[]> ] [-Credential <System.Management.Automation.PSCredential[]> ] [-LogicalSectorSizeBytes <UInt32> {512 | 4096} ] [-PhysicalSectorSizeBytes <UInt32> {512 | 4096} ] [-Confirm] [-WhatIf] [ <CommonParameters>]
Parameter Set: FixedWithSource
New-VHD [-Path] <String[]> -Fixed -SourceDisk <UInt32> [-AsJob] [-BlockSizeBytes <UInt32> ] [-CimSession <Microsoft.Management.Infrastructure.CimSession[]> ] [-ComputerName <String[]> ] [-Credential <System.Management.Automation.PSCredential[]> ] [-Confirm] [-WhatIf] [ <CommonParameters>]
详细说明
The New-VHD cmdlet creates one or more new virtual hard disks in either VHD format or the newer VHDX format. The file name extension you specify determines the format.
参数
-AsJob
Runs the cmdlet as a background job.
别名 |
none |
是否必需? |
false |
在哪里? |
named |
默认值 |
none |
是否接受管道输入? |
false |
是否接受通配符? |
false |
-BlockSizeBytes<UInt32>
Specifies the block size, in bytes, of the virtual hard disk to be created.
别名 |
none |
是否必需? |
false |
在哪里? |
named |
默认值 |
none |
是否接受管道输入? |
false |
是否接受通配符? |
false |
-CimSession<Microsoft.Management.Infrastructure.CimSession[]>
在远程会话中或远程计算机上运行该 cmdlet。输入计算机名或会话对象,如 New-cimsession 或 Get-cimsession cmdlet 的输出。默认为本地计算机上的当前会话。
别名 |
none |
是否必需? |
false |
在哪里? |
named |
默认值 |
none |
是否接受管道输入? |
false |
是否接受通配符? |
false |
-ComputerName<String[]>
Specifies one or more Hyper-V hosts on which the virtual hard disk file(s) are to be created. NetBIOS names, IP addresses, and fully qualified domain names are allowable. The default is the local computer. Use localhost or a dot (.) to specify the local computer explicitly.
别名 |
none |
是否必需? |
false |
在哪里? |
named |
默认值 |
none |
是否接受管道输入? |
false |
是否接受通配符? |
false |
-Credential<System.Management.Automation.PSCredential[]>
Specifies one or more user accounts that have permission to perform this action. The default is the current user.
别名 |
none |
是否必需? |
false |
在哪里? |
named |
默认值 |
none |
是否接受管道输入? |
false |
是否接受通配符? |
false |
-LogicalSectorSizeBytes<UInt32>
Specifies the logical sector size, in bytes, of the virtual hard disk to be created. Valid values are 512 and 4096.
别名 |
none |
是否必需? |
false |
在哪里? |
named |
默认值 |
none |
是否接受管道输入? |
false |
是否接受通配符? |
false |
-ParentPath<String>
Specifies the path to the parent of the differencing disk to be created (this parameter may be specified only for the creation of a differencing disk).
别名 |
none |
是否必需? |
true |
在哪里? |
2 |
默认值 |
none |
是否接受管道输入? |
false |
是否接受通配符? |
false |
-Path<String[]>
Path to the new virtual hard disk file(s) that is being created as a result of a command. If a filename or relative path is specified, the new virtual hard disk path is calculated relative to the current working directory.
别名 |
none |
是否必需? |
true |
在哪里? |
1 |
默认值 |
none |
是否接受管道输入? |
True (ByValue, ByPropertyName) |
是否接受通配符? |
false |
-PhysicalSectorSizeBytes<UInt32>
Specifies the physical sector size, in bytes. Valid values are 512 and 4096.
别名 |
none |
是否必需? |
false |
在哪里? |
named |
默认值 |
none |
是否接受管道输入? |
false |
是否接受通配符? |
false |
-SizeBytes<UInt64>
The maximum size, in bytes, of the virtual hard disk to be created.
别名 |
none |
是否必需? |
true |
在哪里? |
2 |
默认值 |
none |
是否接受管道输入? |
false |
是否接受通配符? |
false |
-SourceDisk<UInt32>
Specifies the physical disk to be used as the source for the virtual hard disk to be created.
别名 |
Number |
是否必需? |
true |
在哪里? |
named |
默认值 |
none |
是否接受管道输入? |
True (ByPropertyName) |
是否接受通配符? |
false |
-Differencing
Specifies that a differencing virtual hard disk is to be created.
别名 |
none |
是否必需? |
false |
在哪里? |
named |
默认值 |
none |
是否接受管道输入? |
false |
是否接受通配符? |
false |
-Dynamic
Specifies that a dynamic virtual hard disk is to be created.
别名 |
none |
是否必需? |
true |
在哪里? |
named |
默认值 |
none |
是否接受管道输入? |
false |
是否接受通配符? |
false |
-Fixed
Specifies that a fixed virtual hard disk is to be created.
别名 |
none |
是否必需? |
true |
在哪里? |
named |
默认值 |
none |
是否接受管道输入? |
false |
是否接受通配符? |
false |
-Confirm
在运行 cmdlet 前提示你进行确认。
是否必需? |
false |
在哪里? |
named |
默认值 |
false |
是否接受管道输入? |
false |
是否接受通配符? |
false |
-WhatIf
显示在 cmdlet 运行时将发生的情况。该 cmdlet 不运行。
是否必需? |
false |
在哪里? |
named |
默认值 |
false |
是否接受管道输入? |
false |
是否接受通配符? |
false |
<CommonParameters>
此 cmdlet 支持常见的参数:-Verbose、-Debug、-ErrorAction、-ErrorVariable、-OutBuffer 和 -OutVariable。有关详细信息,请参阅 TechNet 上的 about_CommonParameters (https://go.microsoft.com/fwlink/p/?LinkID=113216)。
输入
输入类型是可以传送到 cmdlet 的对象的类型。
输出
输出类型是 cmdlet 发出的对象的类型。
- VHDObject[]
示例
Example 1
This example creates a dynamic virtual hard disk in VHDX format that is 10 GB in size. The file name extension determines the format and the default type of dynamic is used because no type is specified.
PS C:\> New-VHD –Path c:\Base.vhdx –SizeBytes 10GB
Example 2
This example creates a VHDX-format differencing virtual hard disk with a parent path of c:\Base.vhdx.
PS C:\> New-VHD –ParentPath c:\Base.vhdx –Path c:\Diff.vhdx -Differencing
Example 3
This example creates a 1 TB VHD-format fixed virtual hard disk at the specified path. The data for the virtual hard disk is populated from the disk identified in the system by the number 2. You can list the disks attached to the system and the number associated with each disk using the Get-Disk cmdlet.
PS C:\> New-VHD -Path C:\fixed.vhd –Fixed –SourceDisk 2 –SizeBytes 1TB
Example 4
This example creates a new 1 TB VHDX-format dynamic virtual hard disk at the specified path with a block size of 128 MB and a logical sector size of 4 KB.
PS C:\> New-VHD –Path c:\LargeSectorBlockSize.vhdx –BlockSizeBytes 128MB –LogicalSectorSize 4KB –SizeBytes 1TB
Example 5
This example creates a new 127GB VHD and then mounts, initializes, and formats it so the drive is ready to use.
PS C:\> $vhdpath = "C:\VHDs\Test.vhdx"
PS C:\> $vhdsize = 127GB
PS C:\> New-VHD -Path $vhdpath -Dynamic -SizeBytes $vhdsize | Mount-VHD -Passthru |Initialize-Disk -Passthru |New-Partition -AssignDriveLetter -UseMaximumSize |Format-Volume -FileSystem NTFS -Confirm:$false -Force