PowerEdge: Cleaning S2D Disks and destruction of old Storage Spaces Direct
Summary: How to Clear Storage spaces direct while leaving data on USB drives.
Instructions
Cleaning S2d Disks and destruction of old Storage Spaces Direct
Be Advised this destroys data! This script prepares a pool to redeploy!
This guide and other Guides have a Microsoft Script which cleans the Storage pool to be able to redeploy a Storage Spaces Direct pool.
Deploy Storage Spaces Direct on Windows Server | Microsoft Learn.
Deploy Storage Spaces Direct on Windows Server | Microsoft Learn.
The Problem with this script is it any USB data is gone including any drives which may be plugged in. USB drives are often used with remote deployments. Running this script included below can result in unintended data loss. The script below prevents a drive to the site again to replace the data on the USB device.
The Adjusted Script is below. This script does not delete USB drive data.
$ServerList = "Server1", "Server2", "Server3"
Invoke-Command ($ServerList) {
Update-StorageProviderCache
Get-StoragePool | ? IsPrimordial -eq $false | Set-StoragePool -IsReadOnly:$false -ErrorAction SilentlyContinue
Get-StoragePool | ? IsPrimordial -eq $false | Get-VirtualDisk | Remove-VirtualDisk -Confirm:$false -ErrorAction SilentlyContinue
Get-StoragePool | ? IsPrimordial -eq $false | Remove-StoragePool -Confirm:$false -ErrorAction SilentlyContinue
Get-PhysicalDisk | Reset-PhysicalDisk -ErrorAction SilentlyContinue
Get-Disk | ? Number -ne $null | ? IsBoot -ne $true | ? IsSystem -ne $true | ? PartitionStyle -ne RAW | ? BusType -ne USB | % {
$_ | Set-Disk -isoffline:$false
$_ | Set-Disk -isreadonly:$false
$_ | Clear-Disk -RemoveData -RemoveOEM -Confirm:$false
$_ | Set-Disk -isreadonly:$true
$_ | Set-Disk -isoffline:$true
}
Get-Disk | Where Number -Ne $Null | Where IsBoot -Ne $True | Where IsSystem -Ne $True | Where PartitionStyle -Eq RAW | Group -NoElement -Property FriendlyName
} | Sort -Property PsComputerName, Count