Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Commit

Permalink
gh-45: Add rescan operation to detect disk change and use diskpart
Browse files Browse the repository at this point in the history
  • Loading branch information
Alejandro Huertas authored and Vlastimil Holer committed Feb 19, 2019
1 parent ad21f1d commit 388acc2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion context.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -640,10 +640,13 @@ function extendPartitions()
{
Write-Output "- Extend partitions"

"rescan" | diskpart

#$diskIds = ((wmic diskdrive get Index | Select-String "[0-9]+") -replace '\D','')
$diskId = 0

$partIds = ((wmic partition where DiskIndex=$diskId get Index | Select-String "[0-9]+") -replace '\D','' | %{[int]$_ + 1})
#$partIds = ((wmic partition where DiskIndex=$diskId get Index | Select-String "[0-9]+") -replace '\D','' | %{[int]$_ + 1})
$partIds = "select disk $diskId", "list partition" | diskpart | Select-String -Pattern "^ Partition \d" -AllMatches | %{$_.matches} | %{$_.value.replace(" Partition ", "") }

ForEach ($partId in $partIds) {
extendPartition $diskId $partId
Expand Down

0 comments on commit 388acc2

Please sign in to comment.