All of our servers are getting their Disk allocations increased. I have no desire to type:
Select disk 6
Select Partition 1
Extend
Select disk 7
Select Partitio
Same solution but more simple, and it works with other locales too:
function Extend-Partition($disk, $part)
{
"select disk $disk","select partition $part","extend" | diskpart | Out-Null
}
$disks = ((wmic diskdrive get Index | Select-String "[0-9]+") -replace '\D','')
ForEach ($disk in $disks) {
$parts = ((wmic partition where DiskIndex=$diskId get Index | Select-String "[0-9]+") -replace '\D','' | %{[int]$_ + 1})
ForEach ($part in $parts) {
Extend-Partition $disk $part
}
}