And then there was this bunch of servers which all needed their disks expanded and a question:

What takes longer: logging into each of the servers, opening the disk management and expanding the disk size manually … or let PowerShell do the job?


Expand a specified disk on multiple servers at once while drinking coffee.


        Expands disks to their maximum possible size.
        Use this script to enter a list of servers and a driveletter to expaned the specified drives to their max on each of the servers from remote.
    .PARAMETER pathToServerList
        Path to a textfile containing a list of server FQDNs to be altered (one FQDN per row).
    .PARAMETER driveLetter
        Letter of the drive to be maxxed.
        Expand-Disks.ps1 -PathToServerList = "C:\temp\Servers_SCCM.txt" -DriveLetter D

    param (
        [Parameter(Mandatory=$true, Position = 1)][string]$pathToServerlist,
        [Parameter(Mandatory=$true, Position = 2)][string]$driveLetter

$servers = Get-Content $pathToServerlist

foreach ($server in $servers) {
     Invoke-Command -ComputerName $server -ScriptBlock {
        $maxSize = (Get-PartitionSupportedSize -DriveLetter $Using:driveLetter).Sizemax
        Resize-Partition -DriveLetter $Using:driveLetter -Size $maxSize


The best thing about this script actually is that invoking the command on each of the servers is slow enough to both make AND drink coffee while it’s running.