How to extend the disk from existing disk in powershell

D Vijayakumar VLR 126 Reputation points
2022-02-10T05:25:48.25+00:00

Hi All,

I want to extend disk size 5GB or 10 GB in existing disk and i have windows and linux servers in vcenter i find VM with edit settings shows 5 Hard disk in VM (Hard disk 1, Hard disk 2, Hard disk 3, Hard disk 4 like that). i need to extend the hard disk 3 and 4 each 5 GB need to extend on multiple remote servers around 12 servers through powershell script guide me and teach me to learn new things it will helpfull for me.

Windows Server 2012
Windows Server 2012
A Microsoft server operating system that supports enterprise-level management, data storage, applications, and communications.
1,529 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,363 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Clément BETACORNE 2,031 Reputation points
    2022-02-15T09:58:25.33+00:00

    Hello,

    Did you try that :

    # Variable specifying the drive you want to extend  
    $drive_letter = "C"  
      
    # Script to get the partition sizes and then resize the volume  
    $size = (Get-PartitionSupportedSize -DriveLetter $drive_letter)  
    Resize-Partition -DriveLetter $drive_letter -Size $size.SizeMax  
    

    You can find more information in this article :
    https://learn.microsoft.com/en-us/windows-server/storage/disk-management/extend-a-basic-volume

    Regards,

    1 person found this answer helpful.