Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade

How to Resize a Volume in Windows Using PowerShell

In the Windows environment, managing disk space is crucial for maintaining system performance and ensuring that applications have enough space to operate efficiently. One common task is resizing a volume, which involves either expanding or shrinking the storage capacity allocated to a particular drive. Unlike some operating systems that might use specific commands like "Resize-Volume," Windows provides robust tools such as Disk Management and PowerShell for this purpose. This article will guide you through resizing a volume using PowerShell, a powerful scripting language and command-line shell that is integral to Windows system administration.

Examples:

  1. Expanding a Volume Using PowerShell

    To expand a volume, you first need to identify the disk and partition you want to modify. Here's how you can do it:

    # Get the list of disks
    Get-Disk
    
    # Get the list of partitions on a specific disk (e.g., Disk 0)
    Get-Partition -DiskNumber 0
    
    # Resize the partition (e.g., Partition 2 on Disk 0) to use all available space
    Resize-Partition -DiskNumber 0 -PartitionNumber 2 -Size (Get-PartitionSupportedSize -DiskNumber 0 -PartitionNumber 2).SizeMax
  2. Shrinking a Volume Using PowerShell

    Shrinking a volume can be a bit more complex because you need to ensure there's enough free space to reduce the size. Here's an example:

    # Get the list of disks
    Get-Disk
    
    # Get the list of partitions on a specific disk (e.g., Disk 0)
    Get-Partition -DiskNumber 0
    
    # Check the current size and free space of the partition
    Get-Partition -DiskNumber 0 -PartitionNumber 2 | Get-PartitionSupportedSize
    
    # Shrink the partition (e.g., Partition 2 on Disk 0) to a new size (in bytes)
    Resize-Partition -DiskNumber 0 -PartitionNumber 2 -Size 50000000000
  3. Checking Partition Sizes

    Before and after resizing, you may want to check the sizes of your partitions to ensure the operation was successful:

    # Get the list of partitions and their sizes on a specific disk (e.g., Disk 0)
    Get-Partition -DiskNumber 0 | Select-Object -Property PartitionNumber, Size

To share Download PDF

Gostou do artigo? Deixe sua avaliação!
Sua opinião é muito importante para nós. Clique em um dos botões abaixo para nos dizer o que achou deste conteúdo.