Skip to content

Instantly share code, notes, and snippets.

@jhochwald
Created December 28, 2016 13:33
Show Gist options
  • Save jhochwald/8c0a900f30700effc9964fe0ff113fbd to your computer and use it in GitHub Desktop.
Save jhochwald/8c0a900f30700effc9964fe0ff113fbd to your computer and use it in GitHub Desktop.
Creates a new Storage Space with a SSD and a HDD Tier for my Hyper-V Server
#requires -Version 3.0 -Modules Storage
# Get all Physical Disks
<#
.SYNOPSIS
Create a new Storage Space for my Hyper-V Server
.DESCRIPTION
Creates a new Storage Space with a SSD and a HDD Tier for my Hyper-V Server
.EXAMPLE
PS C:\>
.NOTES
In this case we have
2 Physical Disks with 6TB each and we mirror all Data,
2 SSD Devices with 119GB each for Pining, Speed and WriteBack Caching
#>
$PhysicalDisks = (Get-PhysicalDisk -CanPool $True | Where-Object -Property MediaType -NE -Value UnSpecified)
# Create the new Storage Pool
$null = (New-StoragePool -PhysicalDisks $PhysicalDisks -StorageSubSystemFriendlyName 'Windows Storage*' -FriendlyName 'LocalData')
# Put all SSD Drives in a new Tier
$SSD_Tier = (New-StorageTier -StoragePoolFriendlyName 'LocalData' -FriendlyName SSD_Tier -MediaType SSD)
# Put all Disk in a new Tier
$HDD_Tier = (New-StorageTier -StoragePoolFriendlyName 'LocalData' -FriendlyName HDD_Tier -MediaType HDD)
<#
Create a new Disk with the following data:
5.4TB of Harddisks
60GB of Speed Space on the SSDs
55GB of Writeback Cache on the SSDs
#>
$null = (New-VirtualDisk -StoragePoolFriendlyName 'LocalData' -FriendlyName TieredSpace -StorageTiers @($SSD_Tier, $HDD_Tier) -StorageTierSizes @(60GB, 5.4TB) -ResiliencySettingName Mirror -WriteCacheSize 55GB)
# Bring the new Disk we created online and initialize it
$null = (Get-Disk |
Where-Object -Property BusType -EQ -Value Spaces |
Where-Object -Property PartitionStyle -EQ -Value 'RAW' |
Initialize-Disk -PartitionStyle GPT)
# Create a new Drive on the new newly created Disk
$null = (Get-Disk |
Where-Object -Property BusType -EQ -Value Spaces |
New-Partition -UseMaximumSize -DriveLetter Z |
Format-Volume -FileSystem ReFS -NewFileSystemLabel 'DATA' -Confirm:$False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment