In this series I will introduce you to Windows PowerShell disk management. In today's post I review some general disk management concepts.
Latest posts by Surender Kumar (see all)

Every Windows system administrator must deal with disks and storage (either physical or virtual) on a regular basis. While a few utilities (such as disk management and diskpart) are built into Windows that you can use to perform various disk management tasks, there are still some folks who love doing things with PowerShell. In this series of three posts, I will discuss all the PowerShell needed to manage disks.

In this article, I will try to cover most of the disk and storage management tasks that an administrator might need to perform—all with the help of Windows PowerShell.

Data loss warning ^

The commands in this series deal with various disk management activities, such as partitioning, formatting, converting, resizing, etc., which could cause permanent data loss. It is highly recommended that you back up your important data before running these commands. I will not be held responsible for any data loss incurred due to an incorrect command.

Disk partitioning schemes ^

The disk partitioning scheme defines how the boot structure and data are handled by the disk. When you attach a new disk in Windows and open the disk management utility, it asks you to initialize the disk with either the master boot record (MBR) or the globally unique identifier partition table (GPT) partition style. Let me briefly explain these partition schemes.

  • MBR—The MBR is an old-fashioned partitioning scheme that has a limit of a maximum of four primary partitions and a maximum supported disk size of 2 TB.
  • GPT—The GPT is a modern partitioning scheme that is more resilient and reliable and does not suffer from the limitations of the MBR scheme.

Limitations of MBR partitioning ^

  • The MBR scheme allows the creation of a maximum of four primary partitions. If you want more, you need to create three primary partitions and one extended partition. The extended partition can be further partitioned into logical drives.
  • With the MBR scheme, the maximum supported disk size is up to 2 TB. If you initialize a 4 TB drive as MBR, the disk will recognize the 2 TB space only, and the rest of the space will be wasted.
  • The MBR scheme is supported by systems with legacy BIOS firmware.
  • The MBR scheme is more prone to errors, corruption, and data loss.

Benefits of GPT partitioning ^

  • As it is a modern specification, the GPT supports an almost unlimited number of partitions. However, the Windows implementation restricts this limit to 128 partitions.
  • With the GPT scheme, the maximum supported GPT disk size can be up to 9.4 ZB (1 ZB = 1 billion TBs), which is way too much for current storage drives.
  • The GPT scheme is supported by systems with Unified Extensible Firmware Interface (UEFI) firmware.
  • The GPT scheme is more resilient to errors and corruption, which makes it more reliable than MBR.
  • The GPT scheme provides a cyclic redundancy check (CRC) for data integrity.

Windows 10 and later now has native support for GPT disks, which means you can install Windows on a GPT disk, and it will work just fine as long as your system supports the UEFI firmware. Therefore, the GPT partition scheme is recommended for new disks, particularly if your disk is larger than 2 TB. The MBR scheme is only useful for compatibility with legacy systems that do not support UEFI firmware.

Finding suitable PowerShell disk management cmdlets ^

Before actually diving into the disk and storage management stuff, let me tell you a trick for finding a cmdlet in PowerShell that might be suitable for your needs. Remember that PowerShell cmdlets follow a "Verb-Noun" nomenclature. This means that almost every cmdlet has a "Verb" part and a "Noun" part separated by a "-" character (for example, Get-Service).

The "Verb" part of the cmdlet generally has fewer options, such as Get, Set, New, Remove, Start, Stop, Enable, Disable, Clear, etc. The Verb part in the cmdlet is usually self-descriptive.

Remember these rules of thumb:

  • When you're trying to show or view something, you will use the cmdlets containing the "Get" verb.
  • When you're trying to modify or update something, you'll use the cmdlets containing the "Set" verb.
  • When you're trying to create or add something, you will use the cmdlets containing the "New" verb.
  • When you're trying to delete or remove something, you will use the cmdlets containing the "Remove" or "Clear" verb.

Please be aware that these rules are not always strictly followed, but they work most of the time.

To figure out the "Noun" part of the cmdlet, you have to make an educated guess, depending upon the operation you will be performing. For example, we'll be dealing with storage and disks in this guide. So, most probably, the "Noun" part of our cmdlet should contain a "disk" keyword. Now, to get the information about a disk, the name of the cmdlet should look something like "Get-Disk." Do you get the idea of how the cmdlet names are chosen in PowerShell?

Furthermore, PowerShell has a Get-Command cmdlet that you can always use to figure out the cmdlet of your choice. It allows you to specify -Verb and -Noun parameters. We will use it in the next section. With the help the wildcard you can easily find the name of the right PowerShell disk management cmdlets.

Subscribe to 4sysops newsletter!

Get-Command *-disk
Finding PowerShell disk managment cmdlets

Finding PowerShell disk managment cmdlets

In the next post of my PowerShell disk management series, I will discuss the PowerShell storage module and its cmdlets for initializing, partitioning, formatting, and resizing disks.

Articles in series

Windows PowerShell disk management

4 Comments
  1. bgavin 2 months ago

    I am looking forward to more articles about Powershell and disk management.
    One point to consider: GPT is far more fragile and easy to corrupt, than is MBR.

    As a servicer, I see far more corruption problems with UEFI enabled systems, than with MBR.
    Please consider one of your articles to be a deep dive into the repair of UEFI systems that fail to boot.
    The Windows repair process never has any success at correcting UEFI problems.

    • Author
      Surender Kumar 2 months ago

      More posts are coming up on Disk Management with PowerShell.

      As far as GPT disks are concerned, they are not fragile. It could be in your perspective but GPT standard is much more improved in terms of data storage and resiliency.
      MBR disks used to store the partition table information only at once place. If something goes wrong with that – the disk becomes unreadable. GPT on the other hand contains a backup partition table to recover from such situation. The built-in CRC is another advantage of GPT which helps in data integrity.

      Please don’t consider GPT a Windows-only thing. You could say that Windows is fragile on GPT disks 🙂

  2. Marc 2 months ago

    Great intro article, looking forward to the next ones!

    Regarding finding the commands at the bottom. I’m certain you already know these things but for other readers it could be helpful. You mentioned using -verb and -noun so a good example could also be “Get-Command -noun disk” (or *disk*). Then building out further, noting that the Source for the results were all Storage you could follow this with “Get-Command -Module Storage”.

  3. bgavin 2 months ago

    I am speaking from the point of view of the IT servicer, not a theoretical viewpoint.

    In the real world, MBR disks can be reinitialized with a simple command.
    In the real world when a UEFI disk fails to boot after a Windows update, FAR more effort is required to correct the corruption.

    I simply do not see disks with MBR problems, but I have seen far too many disks with UEFI problems after a Windows update.

Leave a reply

Your email address will not be published.

*

© 4sysops 2006 - 2022

CONTACT US

Please ask IT administration questions in the forums. Any other messages are welcome.

Sending

Log in with your credentials

or    

Forgot your details?

Create Account