Skip to content

Instantly share code, notes, and snippets.

@lantrix
Created October 23, 2014 06:20
Show Gist options
  • Select an option

  • Save lantrix/e9e170f1b3c645c67d10 to your computer and use it in GitHub Desktop.

Select an option

Save lantrix/e9e170f1b3c645c67d10 to your computer and use it in GitHub Desktop.
Create Striped Volume set a Single (only 1 available) Raw Disk
#
# Create Striped Volume set a Single (only 1 available) Raw Disk
#
#settings
$letter = "F" #Drive Letter
$allocation = 65536 #Blocksize in Bytes
$label = "Master F: Logs" #drive label
#Get started
$disk = get-disk |where partitionstyle -eq 'raw'
if ($disk.Count -gt 1) {throw "Too many RAW disks"}
if ($disk.Count -eq 0) {throw "No RAW disks"}
#Prepare diskpart Script for disk
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 += "create volume simple disk=$($disk.Number)"+[char][int](13)+[char][int](10); #Select Disk
$a += "format fs=NTFS unit=$allocation label=`"$label`" quick "+[char][int](13)+[char][int](10); #Format Vol
$a += "assign letter=$letter "+[char][int](13)+[char][int](10); #Assign Drive Letter
$a += "exit"+[char][int](13)+[char][int](10);
$a | Set-Content c:\diskpart.txt -Encoding ASCII
#Execute script for disk
& Diskpart /s c:\diskpart.txt
Remove-Item c:\diskpart.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment