Optimize-VirtualDisk

2024.6.2

Defragments partitions of a virtual hard disk using the Optimize-Volume cmdlet and optimizes the virtual hard disk
file using Optimize-VHD.

This cmdlet can be used on virtual hard disk files (VHD or VHDX) on disk, or on virtual machines.

When targeting virtual machines, the virtual machine will have its virtual hard disk files defragmented and
optimized only i
Defragments partitions of a virtual hard disk using the Optimize-Volume cmdlet and optimizes the virtual hard disk
file using Optimize-VHD.

This cmdlet can be used on virtual hard disk files (VHD or VHDX) on disk, or on virtual machines.

When targeting virtual machines, the virtual machine will have its virtual hard disk files defragmented and
optimized only if the virtual machine does not have a snapshot, and if its virtual hard disk files are not part of
another virtual machine's snapshot.

------------- The Optimization Process -------------

Only partitions with drive letters (e.g.: C:\) will be defragmented. Partitions without drive letters will be
skipped.

For each valid partition on the virtual hard disk the following commands will be ran:

   Optimize-Volume -Defrag is ran on the partition.
       All files on the partition are defragmented to be contiguous

   Optimize-Volume -SlabConsolidate -ReTrim is ran on the partition.
       All defragmented data is consolidated towards the start of the partition and excess file size is trimmed.

   Optimize-Volume -Defrag is ran on the partition.
       The partition again is defragmented again to ensure no leftover fragmentation is present from moving data
during the slab consolidation and re-trim.

   Optimize-Volume -SlabConsolidate is ran on the partition.
       All defragmented data is consolidated once more towards the start of the partition.

After all partitions are defragmented the optimization concludes with running Optimize-VHD on the virtual hard
disk.
Show more

Minimum PowerShell version

5.1

Installation Options

Copy and Paste the following command to install this package using PowerShellGet More Info

Install-Module -Name Optimize-VirtualDisk

Copy and Paste the following command to install this package using Microsoft.PowerShell.PSResourceGet More Info

Install-PSResource -Name Optimize-VirtualDisk

You can deploy this package directly to Azure Automation. Note that deploying packages with dependencies will deploy all the dependencies to Azure Automation. Learn More

Manually download the .nupkg file to your system's default download location. Note that the file won't be unpacked, and won't include any dependencies. Learn More

Owners

Copyright

Copyright (c) 2024 AJ Tek Corporation. All Rights Reserved.

Requires License Acceptance

View License.txt

Package Details

Author(s)

  • AJ Tek Corporation

Tags

Defrag Optimize Optimise VHD VHDX

Functions

Optimize-VirtualDisk

PSEditions

Desktop Core

Dependencies

This module has no dependencies.

FileList

Version History

Version Downloads Last updated
2024.6.2 (current version) 164 6/6/2024