Advertisement
rj07thomas

Extend a disk

Aug 19th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. Clear-Host
  2.  
  3. Write-Host "This script starts by displaying the disks & associated partitions in a system.`nIt asks you to pick a disk and a partitions based on that list"
  4.  
  5. #This is critical; it rescans the storage, otherwise Windows won't have realised the disk has been extended
  6. Update-HostStorageCache
  7.  
  8. Get-Partition | Format-Table DiskNumber,DriveLetter,PartitionNumber
  9.  
  10. $chooseDisk = Read-Host "Please pick a disk number"
  11. $choosePartition = Read-Host "Please pick a partition number"
  12.  
  13. $supportedSize = Get-PartitionSupportedSize -DiskNumber $chooseDisk -PartitionNumber $choosePartition
  14.  
  15. $sizeMax = [math]::Round($supportedSize.SizeMax / 1TB,1)
  16. Resize-Partition -DiskNumber 1 -PartitionNumber 2 -Size $supportedSize.SizeMax
  17.  
  18. Write-Host "`nI've just extended the partition to" $sizeMax "TB"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement