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

anil suthar 1 Reputation point
2021-09-28T09:33:39.973+00:00

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.
5,362 questions
0 comments No comments
{count} votes

5 answers

Sort by: Most helpful
  1. Rich Matheisen 44,776 Reputation points
    2021-09-28T15:02:39.17+00:00

    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 15,141 Reputation points
    2021-09-29T07:01:37.257+00:00

    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:

    https://www.tenforums.com/tutorials/85750-convert-mbr-disk-gpt-disk-windows-10-a.html

    https://www.tenforums.com/tutorials/84888-check-if-disk-mbr-gpt-windows.html

    .
    .
    .
    .
    .
    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
    2021-09-29T07:29:29.667+00:00

    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 44,776 Reputation points
    2021-09-29T14:31:05.15+00:00

    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 39,351 Reputation points
    2021-10-01T10:33:20.93+00:00

    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

    https://learn.microsoft.com/en-us/windows-server/storage/disk-management/initialize-new-disks#about-partition-styles---gpt-and-mbr

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

    https://learn.microsoft.com/en-us/windows-server/storage/disk-management/initialize-new-disks

    -------------------------------------------------------------------------------------------------------------------------

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

    0 comments No comments