Last active
July 1, 2018 01:27
-
-
Save ksasao/0feabd44a72eac18db29682d82ce8f3a to your computer and use it in GitHub Desktop.
Create blank .vhdx virtual disk using PowerShell
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
| $vhdPath="sample.vhdx" | |
| $vhdSize = 20GB | |
| $driveLetter = "E" | |
| $label = "Data" | |
| $fileSystem = "NTFS" | |
| New-VHD -Path $vhdPath -Dynamic -SizeBytes $vhdSize | |
| Mount-VHD -Path $vhdPath | |
| $disk = get-vhd -path $vhdPath | |
| Initialize-Disk $disk.DiskNumber | |
| $partition = New-Partition -UseMaximumSize -DiskNumber $disk.DiskNumber | |
| Format-Volume -NewFileSystemLabel $label -FileSystem $fileSystem -Confirm:$false -Force -Partition $partition | |
| Set-Partition -DiskNumber $disk.DiskNumber -PartitionNumber $partition.PartitionNumber -NewDriveLetter $driveLetter | |
| Dismount-VHD -Path $vhdPath |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment