This is the built-in help made by Microsoft for the command 'Optimize-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.
Optimizes the allocation of space used by virtual hard disk files, except for fixed virtual hard disks.
Optimize-VHD [-Path] <String[]> [-AsJob] [-ComputerName <String[]>] [-Mode <VhdCompactMode>] [-Passthru] [-Confirm] [-WhatIf] [<CommonParameters>]
The Optimize-VHD cmdlet optimizes the allocation of space in or more virtual hard disk files, except for fixed virtual hard disks. The Compact operation is used to optimize
the files. This operation reclaims unused blocks as well as rearranges the blocks to be more efficiently packed, which reduces the size of a virtual hard disk file.
To use Optimize-VHD, the virtual hard disk must not be attached or must be attached in read-only mode.
The compact operation can succeed without reducing the file size, if no optimization is possible.
<
Online Version: http://go.microsoft.com/fwlink/?LinkID=306901
<
Example 1
PS C:\>Optimize-VHD –Path c:\test\dynamic.vhdx –Mode Full
Runs the compact operation in Full mode. (If the VHDX-format file is not attached as read-only prior to the operation, it will default to Prezeroed mode.)
Example 2
PS C:\> Optimize-VHD –Path c:\test\dynamic.vhdx –Mode Retrim
Runs the compact operation in Retrim mode. (If the VHDX-format disk is not mounted as read-only prior to the operation, running the cmdlet returns an error.)
Example 3
PS C:\>Optimize-VHD –Path c:\test\dynamic.vhdx –Mode Quick
Runs the compact operation in Quick mode. (If the VHDX-format file is not attached as read-only prior to the operation, it defaults to Pretrimmed mode.)