New-VHD

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.

Aliases

none

必須/オプション

false

位置

named

既定値

none

パイプライン入力の受け入れ

false

ワイルドカード文字の受け入れ

false

-BlockSizeBytes<UInt32>

Specifies the block size, in bytes, of the virtual hard disk to be created.

Aliases

none

必須/オプション

false

位置

named

既定値

none

パイプライン入力の受け入れ

false

ワイルドカード文字の受け入れ

false

-CimSession<Microsoft.Management.Infrastructure.CimSession[]>

リモート セッションまたはリモート コンピューターでコマンドレットを実行します。コンピューター名またはセッション オブジェクト (New-CimSession コマンドレットや Get-CimSession コマンドレットの出力など) を入力します。既定値は、ローカル コンピューター上の現在のセッションです。

Aliases

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.

Aliases

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.

Aliases

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.

Aliases

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).

Aliases

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.

Aliases

none

必須/オプション

true

位置

1

既定値

none

パイプライン入力の受け入れ

True (ByValue, ByPropertyName)

ワイルドカード文字の受け入れ

false

-PhysicalSectorSizeBytes<UInt32>

Specifies the physical sector size, in bytes. Valid values are 512 and 4096.

Aliases

none

必須/オプション

false

位置

named

既定値

none

パイプライン入力の受け入れ

false

ワイルドカード文字の受け入れ

false

-SizeBytes<UInt64>

The maximum size, in bytes, of the virtual hard disk to be created.

Aliases

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.

Aliases

Number

必須/オプション

true

位置

named

既定値

none

パイプライン入力の受け入れ

True (ByPropertyName)

ワイルドカード文字の受け入れ

false

-Differencing

Specifies that a differencing virtual hard disk is to be created.

Aliases

none

必須/オプション

false

位置

named

既定値

none

パイプライン入力の受け入れ

false

ワイルドカード文字の受け入れ

false

-Dynamic

Specifies that a dynamic virtual hard disk is to be created.

Aliases

none

必須/オプション

true

位置

named

既定値

none

パイプライン入力の受け入れ

false

ワイルドカード文字の受け入れ

false

-Fixed

Specifies that a fixed virtual hard disk is to be created.

Aliases

none

必須/オプション

true

位置

named

既定値

none

パイプライン入力の受け入れ

false

ワイルドカード文字の受け入れ

false

-Confirm

コマンドレットを実行する前に確認メッセージを表示します。

必須/オプション

false

位置

named

既定値

false

パイプライン入力の受け入れ

false

ワイルドカード文字の受け入れ

false

-WhatIf

コマンドレットが実行された場合に何が起きるのかを示します。コマンドレットは実行されません。

必須/オプション

false

位置

named

既定値

false

パイプライン入力の受け入れ

false

ワイルドカード文字の受け入れ

false

<CommonParameters>

このコマンドレットは共通のパラメーターをサポートしています(-Verbose、-Debug、-ErrorAction、-ErrorVariable、-OutBuffer、および -OutVariable)。詳細については、TechNet の「 「about_CommonParameters」 (https://go.microsoft.com/fwlink/p/?LinkID=113216) を参照してください。

入力

入力型は、コマンドレットにパイプできるオブジェクトの型です。

出力

出力型は、コマンドレットが出力するオブジェクトの型です。

  • 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