Get disk partition style (MBR or GPT) for multiple servers

anil suthar 1 Reputation point

I have 120 servers, i need to know how many servers having MBR partition ? is any script where i can get the details, If its MBR or GPT ? The input would be 120 server names , output to be like server name / Partition name / style. Anyone have please post.

Also anyway to get MBR converted in to GPT without data loss ?

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
4,891 questions
0 comments No comments
{count} votes

5 answers

Sort by: Most helpful
  1. Rich Matheisen 38,831 Reputation points

    The Get-Partition cmdlet will get that information for you.

    Get the list of server names into an array and then use the array as the argument to the ComputerName parameter of Invoke-Command. The script block used on the Invoke-Command will contain the Get-Partition cmdlet and any other code you need to extract the information you need in the format you want. The result will be an array of the results from each server.

  2. Docs 13,466 Reputation points

    The challenge is the number of servers.

    Third party software can be used to convert MBR to GPT without data loss.

    These are commands that could be added to scripts:

    Viewing diskpart > list disk results for each server indicates whether the drive is MBR or GPT.
    Alternatively powershell > get-disk

    These are some links:

    Please remember to vote and to mark the replies as answers if they help.

    On the bottom of each post there is:

    Propose as answer = answered the question

    On the left side of each post: Vote = a helpful post

    0 comments No comments

  3. anil suthar 1 Reputation point

    just sorted the things with below script, i'm struggling to get it extract to excel file. Please help.

    $LogDate = get-date -f yyyyMMddhhmm

    foreach($computer in (get-content D:\disk\servers.txt)){

    Invoke-Command -computername $Computer -scriptblock { Get-Disk } | Select-Object PSComputerName, Number, PartitionStyle

    0 comments No comments

  4. Rich Matheisen 38,831 Reputation points

    Try this:

    Invoke-Command -ComputerName (Get-Content D:\disk\servers.txt) -ScriptBlock {Get-Disk} |
        Select-Object PSComputerName, Number, PartitionStyle |
            Export-Csv c:\junk\disks.csv -NoTypeInformation

    I'm not sure where the $LogDate is used so I just omitted it from the example.

    You can import the CSV file into Excel.

    0 comments No comments

  5. Limitless Technology 37,751 Reputation points

    Hello Anil,

    If you add a brand new disk to your PC and it doesn't show up in File Explorer, you might need to add a drive letter, or initialize it before using it.

    You can only initialize a drive that's not yet formatted. Initializing a disk erases everything on it and prepares it for use by Windows, after which you can format it and then store files on it.

    Disks can be divided up into multiple chunks called partitions. Each partition - even if you have only one - has to have a partition style - GPT or MBR. Windows uses the partition style to understand how to access the data on the disk.

    Do Check the link below, to get to know About partition styles - GPT and MBR

    Here’s a link that will help guide you as well:


    If an Answer is helpful, please click "Accept Answer" and upvote it : )

    0 comments No comments