powershell upgrade HD code

Discussion in 'Windows Server, Hyper-V Virtualization' started by cesmith9999, Feb 23, 2015.

  1. cesmith9999

    cesmith9999 Well-Known Member

    Joined:
    Mar 26, 2013
    Messages:
    1,099
    Likes Received:
    333
    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' }
    $MissingDisk

    #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}
    $ReplacementDisk
    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"}
    $VDisk

    #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.
     
    #1
    Last edited: Sep 10, 2015
    Patrick likes this.
Similar Threads: powershell upgrade
Forum Title Date
Windows Server, Hyper-V Virtualization Powershell NIC Command Problem Aug 29, 2018
Windows Server, Hyper-V Virtualization Mellanox WinOF powershell cmdlets not working in Windows 10 (ConnectX-3 SMB Direct/RDMA) Nov 25, 2017
Windows Server, Hyper-V Virtualization WPF application and Powershell Jan 24, 2017
Windows Server, Hyper-V Virtualization Powershell Scripting Question May 12, 2015
Windows Server, Hyper-V Virtualization Server Core: Finally a reason to learn powershell May 6, 2015

Share This Page