{"id":15239,"date":"2013-07-29T13:00:00","date_gmt":"2013-07-29T12:00:00","guid":{"rendered":"https:\/\/aidanfinn.com\/?p=15239"},"modified":"2013-07-29T13:00:00","modified_gmt":"2013-07-29T12:00:00","slug":"build-ws2012-r2-storage-pools-virtual-disks-and-csvs-using-powershell","status":"publish","type":"post","link":"https:\/\/aidanfinn.com\/?p=15239","title":{"rendered":"Build WS2012 R2 Storage Pools, Virtual Disks, And CSVs Using PowerShell"},"content":{"rendered":"<p>I\u2019ve been building, tearing down, and rebuilding Storage Spaces in the lab over and over, and that will continue for the next few years <img decoding=\"async\" class=\"wlEmoticon wlEmoticon-smile\" style=\"border-style: none;\" src=\"https:\/\/aidanfinn.com\/wp-content\/uploads\/2013\/07\/wlEmoticon-smile3.png\" alt=\"Smile\" \/> Rather than spend a significant percentage of my life clicking on wizards, I decided to script what I want done.<\/p>\n<p>The below script will:<\/p>\n<ul>\n<li>Build a storage pool from all available disks<\/li>\n<li>Prep 2 storage tiers from SSD and HDD<\/li>\n<li>Create 3 different virtual disks with different configs (customize to your heat\u2019s content!)<\/li>\n<li>Then run the PrepCSV function to turn those virtual disks into CSVs just the way I like them<\/li>\n<\/ul>\n<p>How do I like a CSV?\u00a0 I like them formatted <img decoding=\"async\" class=\"wlEmoticon wlEmoticon-smile\" style=\"border-style: none;\" src=\"https:\/\/aidanfinn.com\/wp-content\/uploads\/2013\/07\/wlEmoticon-smile3.png\" alt=\"Smile\" \/> and the names consistent all the way: virtual disk, cluster resource name, volume label, and CSV mount point in C:ClusterStorage.\u00a0 None of that \u201cCluster Disk (X)\u201d or \u201cVolume 1\u201d BS for me, thank you.<\/p>\n<p>It might be possible to clean up the stuff in the function.\u00a0 This is what I have working \u2013 it works and that\u2019s the main thing.\u00a0 There\u2019s a lot of steps to get disk ID so I can create and format a volume, and then bring the disk back so I can turn it into a CSV.<\/p>\n<p>What\u2019s missing?\u00a0 I have not added code for adding the SOFS role or adding\/configuring shares.\u00a0 I\u2019m not at that point yet in the lab.<\/p>\n<p>Function PrepCSV ($CSVName)<br \/>\n{<br \/>\n#Rename the disk resource in FCM<br \/>\n(Get-ClusterResource | where {$_.name -like &#8220;*$CSVName)&#8221;}).Name = $CSVName<\/p>\n<p>#Get the disk ID<br \/>\nStop-ClusterResource $CSVName<br \/>\n$DiskID = (Get-VirtualDisk -FriendlyName $CSVName).UniqueId<br \/>\nStart-ClusterResource $CSVName<\/p>\n<p>#Format the disk<br \/>\nSuspend-ClusterResource $CSVName<br \/>\nGet-disk -UniqueId $DiskID | New-Partition -UseMaximumSize | Format-Volume -FileSystem NTFS -NewFileSystemLabel &#8220;$CSVName&#8221; -Confirm:$false<br \/>\nResume-ClusterResource $CSVName<\/p>\n<p>#Bring the CSV online<br \/>\nAdd-ClusterSharedVolume -Name $CSVName<br \/>\n$OldCSVName = ((Get-ClusterSharedVolume $CSVName).SharedVOlumeInfo).FriendlyVolumeName<br \/>\nRename-Item $OldCSVName -NewName &#8220;C:ClusterStorage$CSVName&#8221;<br \/>\n}<\/p>\n<p># The following Storage Pool and Virtual Disk cmdlets taken from Bryan Matthew&#8217;s TechEd\u00a0 &#8230;<br \/>\n# &#8230; Session at <a href=\"http:\/\/channel9.msdn.com\/Events\/TechEd\/Europe\/2013\/MDC-B217#fbid=TFEWNjeU9XP\">http:\/\/channel9.msdn.com\/Events\/TechEd\/Europe\/2013\/MDC-B217#fbid=TFEWNjeU9XP<\/a><\/p>\n<p># Find all eligible disks<br \/>\n$disks = Get-PhysicalDisk |? {$_.CanPool -eq $true}<\/p>\n<p># Create a new Storage Pool<br \/>\nNew-StoragePool -StorageSubSystemFriendlyName &#8220;Clustered Storage Spaces on Demo-FSC1&#8221; -FriendlyName &#8220;Demo-FSC1 Pool1&#8221; -PhysicalDisks $disks<\/p>\n<p># Define the Pool Storage Tiers<br \/>\n$ssd_tier = New-StorageTier -StoragePoolFriendlyName &#8220;Demo-FSC1 Pool1&#8221; -FriendlyName SSD_Tier -MediaType SSD<br \/>\n$hdd_tier = New-StorageTier -StoragePoolFriendlyName &#8220;Demo-FSC1 Pool1&#8221; -FriendlyName HDD_Tier -MediaType HDD<\/p>\n<p>&nbsp;<\/p>\n<p>#Transfer ownership of Available Storage to current node to enable disk formatting<\/p>\n<p>Move-ClusterGroup &#8220;Available Storage&#8221; -Node $env:COMPUTERNAME<\/p>\n<p>&nbsp;<\/p>\n<p># Creation of a 200 GB tiered virtual disk with 5 GB cache<br \/>\nNew-VirtualDisk -StoragePoolFriendlyName &#8220;Demo-FSC1 Pool1&#8221; -FriendlyName CSV1 \u2013StorageTiers @($ssd_tier, $hdd_tier) -StorageTierSizes @(50GB,150GB) -ResiliencySettingName Mirror -WriteCacheSize 5GB<br \/>\nPrepCSV CSV1<\/p>\n<p>&nbsp;<\/p>\n<p># Creation of a 200 GB non-tiered virtual disk with no cache<\/p>\n<p>New-VirtualDisk -StoragePoolFriendlyName &#8220;Demo-FSC1 Pool1&#8221; -FriendlyName CSV2 -Size 200GB -ResiliencySettingName Mirror -WriteCacheSize 0<br \/>\nPrepCSV CSV2<\/p>\n<p>&nbsp;<\/p>\n<p># Creation of a 50 GB virtual disk on SSD only with 5 GB cache<\/p>\n<p>New-VirtualDisk -StoragePoolFriendlyName &#8220;Demo-FSC1 Pool1&#8221; -FriendlyName CSV3 \u2013StorageTiers @($ssd_tier) -StorageTierSizes @(50GB) -ResiliencySettingName Mirror -WriteCacheSize 5GB<br \/>\nPrepCSV CSV3<\/p>\n<p>&nbsp;<\/p>\n<p>EDIT1:<\/p>\n<p>This script broke if the cluster group, Available Storage, was active on another node. \u00a0This prevented formatting, which in turn prevented adding the virtual disks as CSVs. \u00a0Easy fix: move the Available Storage cluster group to the current machine (a node in the cluster).<\/p>\n<p>&nbsp;<\/p>\n<div id=\"scid:0767317B-992E-4b12-91E0-4F059A8CECA8:7697c1ca-511b-4e5c-92bb-ca5b0029876d\" class=\"wlWriterEditableSmartContent\" style=\"float: none; margin: 0px; display: inline; padding: 0px;\">Technorati Tags: <a rel=\"tag\" href=\"http:\/\/technorati.com\/tags\/Windows+Server+2012+R2\">Windows Server 2012 R2<\/a>,<a rel=\"tag\" href=\"http:\/\/technorati.com\/tags\/Failover+Clustering\">Failover Clustering<\/a>,<a rel=\"tag\" href=\"http:\/\/technorati.com\/tags\/Storage\">Storage<\/a>,<a rel=\"tag\" href=\"http:\/\/technorati.com\/tags\/PowerShell\">PowerShell<\/a>,<a rel=\"tag\" href=\"http:\/\/technorati.com\/tags\/Scripting\">Scripting<\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>I\u2019ve been building, tearing down, and rebuilding Storage Spaces in the lab over and over, and that will continue for the next few years Rather than spend a significant percentage of my life clicking on wizards, I decided to script what I want done. The below script will: Build a storage pool from all available &hellip; <a href=\"https:\/\/aidanfinn.com\/?p=15239\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Build WS2012 R2 Storage Pools, Virtual Disks, And CSVs Using PowerShell&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[52],"tags":[63,87,189,99,120],"class_list":["post-15239","post","type-post","status-publish","format-standard","hentry","category-windows-server","tag-failover-clustering","tag-powershell","tag-scripting","tag-storage","tag-windows-server-2012-r2"],"aioseo_notices":[],"jetpack_featured_media_url":"","amp_enabled":true,"_links":{"self":[{"href":"https:\/\/aidanfinn.com\/index.php?rest_route=\/wp\/v2\/posts\/15239","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/aidanfinn.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/aidanfinn.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/aidanfinn.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/aidanfinn.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=15239"}],"version-history":[{"count":0,"href":"https:\/\/aidanfinn.com\/index.php?rest_route=\/wp\/v2\/posts\/15239\/revisions"}],"wp:attachment":[{"href":"https:\/\/aidanfinn.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=15239"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/aidanfinn.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=15239"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/aidanfinn.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=15239"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}