NETWORK ADMINISTRATIONSWindows server

Windows Server Core 2022 Tips & Tricks – Storage Spaces – POWERSHELL EDITION PART 2

Support the channel : (any donation are appreciated) , god bless.

https://paypal.me/ITwizard0?country.x=GB&locale.x=en_GB
https://www.patreon.com/ITWIZ

### On the VM
#Get a list of disks that can be used in a storage pool
Get-PhysicalDisk -CanPool $true

#Get all storage pools
Get-StoragePool

$PhysicalDisks = (Get-PhysicalDisk -CanPool $True)
New-StoragePool -FriendlyName CompanyData -StorageSubsystemFriendlyName “Windows Storage*” -PhysicalDisks $PhysicalDisks
############################################################################################################################
The first line uses the Get-PhysicalDisk cmdlet to get all PhysicalDisk objects that are not yet in a (concrete) storage pool and assigns the array of objects to the $PhysicalDisks variable
The second line creates a new storage pool using the $PhysicalDisks variable
#############################################################################################################################

#To get only the disks in this storage pool
Get-PhysicalDisk -StoragePool (Get-StoragePool CompanyData)

#Get the mediatype of the disks
Get-PhysicalDisk -StoragePool (Get-StoragePool CompanyData) | Select-Object FriendlyName,mediatype,size | Sort-Object size

#You can change the mediatype property for disks
Get-PhysicalDisk -StoragePool (Get-StoragePool CompanyData) | Sort-Object size | Select-Object -First 3 | Set-PhysicalDisk -MediaType SSD
Get-PhysicalDisk -StoragePool (Get-StoragePool CompanyData) | Sort-Object size | Select-Object -First 1 | Set-PhysicalDisk -MediaType HDD

#after you create a pool make sure that this is set otherwise set it (if you do not use hot spare)
Set-StoragePool -FriendlyName ‘CompanyData’ -RetireMissingPhysicalDisks Always

#Restart server to apply this setting

#Create a dual parity disk (for a single parity just do not use -PhysicalDiskRedundancy 2)
New-VirtualDisk -StoragePoolFriendlyName “CompanyData” -FriendlyName “PoolDisk” -Size 178GB -ProvisioningType Thin -ResiliencySettingName “Parity” -PhysicalDiskRedundancy 2

#Create a volume
Get-VirtualDisk –FriendlyName “PoolDisk” | Get-Disk | Initialize-Disk -PartitionStyle GPT –Passthru | New-Partition –AssignDriveLetter –UseMaximumSize | Format-Volume -FileSystem NTFS -Confirm:$false

Disk recovery :

Add-PhysicalDisk -StoragePoolFriendlyName ‘Company Data’ -PhysicalDisks (Get-PhysicalDisk -CanPool $true) -Usage AutoSelect
Get-PhysicalDisk -StoragePool (Get-StoragePool CompanyData) | Where-Object {$_.mediatype -eq ‘UnSpecified’} | Set-PhysicalDisk -MediaType SSD
Remove-PhysicalDisk -StoragePoolFriendlyName CompanyData -PhysicalDisks (Get-PhysicalDisk | Where-Object {$_.OperationalStatus -ne ‘OK’}) -Confirm:$false

source

windows server

Alice AUSTIN

Alice AUSTIN is studying Cisco Systems Engineering. He has passion with both hardware and software and writes articles and reviews for many IT websites.