powershell upgrade HD code


Well-Known Member
Mar 26, 2013
I wrote this script to automate upgrading my 1.5 TB disks to 3 TB disks on my storage spaces.

$MissingDisk = $Null
$ReplacementDisk = $null

#Find Missing disk
$MissingDisk = Get-PhysicalDisk | Where-Object { $_.OperationalStatus -eq 'Lost Communication' }

#retire Missing disk from storagepool
$MissingDisk | Set-PhysicalDisk -Usage Retired

#find replacement disk - assumes that any free disk will get added to the pool.
while ($ReplacementDisk -eq $null) {
$ReplacementDisk = Get-PhysicalDisk | where {$_.canpool -eq $true}
if ($ReplacementDisk -eq $null) {sleep -seconds 10}

#add the replacement disk(s) to the pool
Add-PhysicalDisk -PhysicalDisks $ReplacementDisk -StoragePoolFriendlyName StoragePool01

#look at the health of the virtual disks
$VDisk = get-virtualdisk | where {$_.OperationalStatus -like "Degraded"}

#rebuild the virtual disks - smallest to largest
foreach ($vd in $VDisk | sort allocatedsize ) {repair-virtualdisk $vd.friendlyname}

#remove the failed disk form the pool - manual confirmation
remove-physicaldisk -PhysicalDisks $MissingDisk -StoragePoolFriendlyName StoragePool01 -confirm:$false

To be honest. I stole some of this code from someone else's webpage. but I definitely made this my own.
Last edited:
  • Like
Reactions: Patrick