Last active
August 29, 2015 14:08
-
-
Save lantrix/62450df9ab94e68d7992 to your computer and use it in GitHub Desktop.
Create Striped Volume set from (Available) Raw Disks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # | |
| # Create Striped Volume set from (Available) Raw Disks | |
| # | |
| #settings | |
| $letter = "E" #Drive Letter | |
| $allocation = 65536 #Blocksize in Bytes | |
| $label = "My Disk Label" #drive label | |
| #Get started | |
| $disks = get-disk |where partitionstyle -eq 'raw' | |
| if ($disks.Count -lt 2) {throw "Not Enough RAW disks"} | |
| #Prepare diskpart Script for each disk | |
| foreach ($disk in $disks) { | |
| Initialize-Disk -PartitionStyle MBR -Number $disk.Number #Bring Online and Initialize | |
| $a = "select disk $($disk.Number)"+[char][int](13)+[char][int](10); #Select Disk | |
| $a += "attributes disk clear readonly noerr "+[char][int](13)+[char][int](10); #set attributes | |
| $a += "convert dynamic noerr "+[char][int](13)+[char][int](10); #convert to dynamic | |
| $a += "exit"+[char][int](13)+[char][int](10); | |
| $a | Set-Content c:\diskpartA_$($disk.Number).txt -Encoding ASCII | |
| } | |
| #Execute script for each disk | |
| foreach ($disk in $disks) { | |
| & Diskpart /s c:\diskpartA_$($disk.Number).txt | |
| Remove-Item c:\diskpartA_$($disk.Number).txt | |
| } | |
| #Prepare striped Volume | |
| $striped = "create volume stripe disk=" | |
| foreach ($disk in $disks) { | |
| #join volumes together for strip set | |
| $striped = $striped + $disk.Number + "," | |
| } | |
| $striped = $striped -replace ".$" #remove last , | |
| $striped = $striped +[char][int](13)+[char][int](10); #add CR/LF | |
| $striped += "format fs=NTFS unit=$allocation label=`"$label`" quick "+[char][int](13)+[char][int](10); #Format Vol | |
| $striped += "assign letter=$letter "+[char][int](13)+[char][int](10); #Assign Drive Letter | |
| $striped += "exit"+[char][int](13)+[char][int](10); | |
| $striped | Set-Content c:\diskpartB.txt -Encoding ASCII | |
| #Execute striped Volume | |
| & Diskpart /s c:\diskpartB.txt | |
| Remove-Item c:\diskpartB.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment