VirtualMetric Hyper-V Monitoring, Hyper-V Reporting


Cozumpark Bilisim Portali
Disk operations with PowerShell v3 on Windows Server 8 Beta – Part 1
Posted in Windows Powershell, Windows Server | No Comment | 6,751 views | 05/03/2012 00:44

In this post, I’ll talk about disk operations on Windows Server 8 Beta. I have Windows 7 and Windows Server 8 Beta on a PC and I want to install Windows 8 Beta as well. I will resize my current Windows Server 8 partition and create a new partition for Windows 8 Beta. When I want to do this operation via Server Manager GUI (in case of you have Server 8 with GUI), I don’t see any option for “Shrink”. Maybe I’m looking to wrong section but here it is:

So lets do this operation via Powershell.

1. First of all lets get partition information.


2. My drive letter is W. So I can get detailed information.

Get-Partition -DiskNumber 1 -PartitionNumber 2

3. Drive size is 373 Gb. I’ll resize it to 250 Gb.

Get-Partition -DiskNumber 1 -PartitionNumber 2 | Resize-Partition -Size 250GB

4. You can see new partition size to confirm operations.

Get-Partition -DiskNumber 1 -PartitionNumber 2

5. Now let’s create our new partition for Windows 8 Beta. I’ll call it “Y” drive.

New-Partition -DiskNumber 1 -DriveLetter Y -UseMaximumSize

Oh! Windows ask me to format drive. This is not what I want. That prompt can be problem in a script. Let’s try it on another way. If we can assign drive letter right after format, then there will be no prompt.

6. Let’s remove the partition first. I know my new partition number is 3.

Remove-Partition -DiskNumber 1 -PartitionNumber 3 -Confirm:$false

7. I’ll create new partition without drive letter and format it.

New-Partition -DiskNumber 1 -UseMaximumSize | Format-Volume -Confirm:$false

8. Now I can assign new drive letter to newly created partition.

Set-Partition -DiskNumber 1 -PartitionNumber 3 -NewDriveLetter Y

Now it’s time to give an example for disk extend.

9. First, I’m resizing my Y drive as 50 GB.

Get-Partition -DriveLetter Y | Resize-Partition -Size 50GB

10. I’m extending it to 75 GB.

Get-Partition -DriveLetter Y | Resize-Partition -Size 75GB

So as you can see there is no difference between shrink and extend on Powershell. For all, you can just use Resize-Partition command.

I hope you find this post useful. I cover following questions in this post:

1. How to create new partition on Windows Server 8 Beta?
2. How to remove partition on Windows Server 8 Beta?
3. How to extend partition on Windows Server 8 Beta?
4. How to shrink partition on Windows Server 8 Beta?
5. How to format partition on Windows Server 8 Beta?

Please let me know if you require additional disk operations.

Applied to: PowerShell v3

Leave a Reply