PowerShell Logo Small

New-VHD



This is the built-in help made by Microsoft for the command 'New-VHD', in PowerShell version 5 - as retrieved from Windows version 'Microsoft Windows Server 2012 R2 Standard' PowerShell help files on 2016-06-23.

For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.

SYNOPSIS

Creates one or more new virtual hard disks.

SYNTAX


New-VHD [-Path] <String[]> [-SizeBytes] <UInt64> [-AsJob] [-BlockSizeBytes <UInt32>] [-ComputerName <String[]>] [-Dynamic] [-LogicalSectorSizeBytes <UInt32>]
[-PhysicalSectorSizeBytes <UInt32>] [-Confirm] [-WhatIf] [<CommonParameters>]
New-VHD [-Path] <String[]> [-ParentPath] <String> [[-SizeBytes] <UInt64>] [-AsJob] [-BlockSizeBytes <UInt32>] [-ComputerName <String[]>] [-Differencing]
[-PhysicalSectorSizeBytes <UInt32>] [-Confirm] [-WhatIf] [<CommonParameters>]
New-VHD [-Path] <String[]> [-AsJob] [-BlockSizeBytes <UInt32>] [-ComputerName <String[]>] -Dynamic -SourceDisk <UInt32> [-Confirm] [-WhatIf] [<CommonParameters>]
New-VHD [-Path] <String[]> [-SizeBytes] <UInt64> [-AsJob] [-BlockSizeBytes <UInt32>] [-ComputerName <String[]>] [-LogicalSectorSizeBytes <UInt32>] [-PhysicalSectorSizeBytes
<UInt32>] -Fixed [-Confirm] [-WhatIf] [<CommonParameters>]
New-VHD [-Path] <String[]> [-AsJob] [-BlockSizeBytes <UInt32>] [-ComputerName <String[]>] -Fixed -SourceDisk <UInt32> [-Confirm] [-WhatIf] [<CommonParameters>]



Search powershellhelp.space

DESCRIPTION


The New-VHD cmdlet creates one or more new virtual hard disks in either VHD format or the newer VHDX format. The file extension you specify determines the format.



<

RELATED LINKS


Online Version: http://go.microsoft.com/fwlink/?LinkID=306895

REMARKS

<

Examples


Example 1

PS C:\> New-VHD –Path c:\Base.vhdx –SizeBytes 10GB



This example creates a dynamic virtual hard disk in VHDX format that is 10 GB in size. The file extension determines the format and the default type of dynamic is used
because no type is specified.




Example 2

PS C:\> New-VHD –ParentPath c:\Base.vhdx –Path c:\Diff.vhdx -Differencing



This example creates a VHDX-format differencing virtual hard disk with a parent path of c:\Base.vhdx.




Example 3

PS C:\> New-VHD -Path C:\fixed.vhd –Fixed –SourceDisk 2 –SizeBytes 1TB



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.




Example 4

PS C:\> New-VHD –Path c:\LargeSectorBlockSize.vhdx –BlockSizeBytes 128MB –LogicalSectorSize 4KB –SizeBytes 1TB



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.




Example 5

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



This example creates a new 127GB VHD and then mounts, initializes, and formats it so the drive is ready to use.