Skip to main content
Jorge Bernhardt Jorge Bernhardt
  1. Posts/

How to create a Virtual Disk using PowerShell

·316 words·2 mins· 100 views · 5 likes ·
Format-Volume Get-VirtualDisk Initialize-Disk Microsoft

In a previous post I showed you how to create a storage pool, today I want to show you how to use PowerShell to create a virtual disk in your Storage Pool.

new-virtualdisk
To create a virtual disk using Powershell, use the New-VirtualDisk cmdlet with the following syntax:

New-VirtualDisk `
    -FriendlyName <String> `
    -StoragePoolFriendlyName <String[]> `
    -Size <UInt64> `
    -ProvisioningType Thin | Fixed `
    -PhysicalDiskRedundancy <UInt16>
-StoragePoolFriendyName Parameter>

-StoragePoolFriendyName Parameter #

To obtain the correct designations for the storage pool, use the cmdlet: Get-StoragePool.

Get-StoragePool

get-storagepool

-ProvisioningType Parameter>

-ProvisioningType Parameter #

Use Thin except when using storage spaces that use storage levels or a clustered storage group in that case use Fixed.

-PhysicalDiskRedundancy Parameter>

-PhysicalDiskRedundancy Parameter #

This value represents how many failed physical disks can tolerate the virtual disk without data loss.

Create the New Virtual Disk>

Create the New Virtual Disk #

Run the following PowerShell commands as administrator.

New-VirtualDisk `
    -FriendlyName 'NewVirtualDisk'  `
    -StoragePoolFriendlyName "StoragePool-01" `
    -Size 10GB `
    -ProvisioningType Thin `
    -PhysicalDiskRedundancy 2

Virtual Disk

Initialize the Virtual Disk>

Initialize the Virtual Disk #

The following command initializes a Disk object with the GPT partition style

Get-VirtualDisk `
    -FriendlyName 'NewVirtualDisk' `
    |Initialize-Disk -PartitionStyle GPT `
    -PassThru

initialize-disk

Partition the Virtual Disk>

Partition the Virtual Disk #

The following command creates a new partition on disk 10, using the maximum available space, and assigning the letter E.

New-Partition `
    -DiskNumber 10 `
    -DriveLetter 'E' `
    -UseMaximumSize

new-partition

Format the Virtual Disk>

Format the Virtual Disk #

The following cmdlet performs a full format of the E volume using the NTFS file system.

Format-Volume `
    -DriveLetter 'E' `
    -FileSystem NTFS `
    -AllocationUnitSize 65536 `
    -Confirm:$false `
    -Force

Virtual Disk PowerShell

Checking>

Checking #

The following cmdlet returns a list of Virtual Disk objects, across all storage pools.

Get-VirtualDisk

Virtual Disk PowerShell

Thanks for reading my post. I hope you find it helpful.

If you want to know more about the New-VirtualDisk cmdlet, check out this link.