Resize-VHD
Resize-VHD
Resizes a virtual hard disk.
Syntax
Parameter Set: Size
Resize-VHD [-Path] <String[]> [-SizeBytes] <UInt64> [-AsJob] [-ComputerName <String[]> ] [-Passthru] [-Confirm] [-WhatIf] [ <CommonParameters>]
Parameter Set: MinimumSize
Resize-VHD [-Path] <String[]> -ToMinimumSize [-AsJob] [-ComputerName <String[]> ] [-Passthru] [-Confirm] [-WhatIf] [ <CommonParameters>]
Detailed Description
The Resize-VHD cmdlet resizes a virtual hard disk. This cmdlet lets you shrink or expand the size of a virtual hard disk, but the shrink operation is allowed only on VHDX virtual hard disks. The shrink operation fails if it would shrink the virtual disk to less than its minimum size (available through the VHDX object’s MinimumSize property).
Resize-VHD is an offline operation; the virtual hard disk must not be attached when the operation is initiated.
Parameters
-AsJob
Specifies that the cmdlet is to be run as a background job.
Aliases |
none |
Required? |
false |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
-ComputerName<String[]>
Specifies one or more Hyper-V hosts on which a virtual hard disk is to be resized. 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 |
Required? |
false |
Position? |
named |
Default Value |
. |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
-Passthru
Specifies that an object is to be passed through to the pipeline representing the virtual hard disk to be resized.
Aliases |
none |
Required? |
false |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
-Path<String[]>
Specifies the path to the virtual hard disk that is to be resized.
Aliases |
none |
Required? |
true |
Position? |
1 |
Default Value |
none |
Accept Pipeline Input? |
true (ByValue, ByPropertyName) |
Accept Wildcard Characters? |
true |
-SizeBytes<UInt64>
Specifies the size to which the virtual hard disk is to be resized.
Aliases |
none |
Required? |
true |
Position? |
2 |
Default Value |
none |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
-ToMinimumSize
Specifies that the virtual hard disk is to be resized to its minimum possible size.
Aliases |
none |
Required? |
true |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
-Confirm
Prompts you for confirmation before running the cmdlet.
Required? |
false |
Position? |
named |
Default Value |
false |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Required? |
false |
Position? |
named |
Default Value |
false |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
<CommonParameters>
This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see about_CommonParameters (https://go.microsoft.com/fwlink/p/?LinkID=113216).
Inputs
The input type is the type of the objects that you can pipe to the cmdlet.
Outputs
The output type is the type of the objects that the cmdlet emits.
Examples
Example 1
Expands the VHDX to 1 terabyte (assuming that the previous size was less than the new size prior to the command).
PS C:\> Resize-VHD –Path c:\BaseVHD.vhd –SizeBytes 1TB
Example 2
Shrinks the VHDX to one terabyte (assuming that the virtual hard disk object associated with the file path has a MinimumSize less than or equal to 1TB).
PS C:\> Resize-VHD –Path c:\BaseVHDX.vhdx –SizeBytes 1TB
Example 3
Shrinks the VHDX to its minimum possible size.
PS C:\> Resize-VHD –Path c:\BaseVHDX.vhdx –ToMinimumSize