How to get partition style from multiple servers using powershell

anil suthar 1 Reputation point
2021-09-29T03:01:35.047+00:00

I have 120 servers, i need to know how many servers having MBR partition & GPT? 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 / disk label / style. Anyone have please post.

Tried script below but doesn't working for 120 servers, it works only for a 1 server.

$ScriptPath = Get-Location

$ServerList = Get-Content "$ScriptPath\servers.txt"

$DiskReport = ForEach ($Servernames in ($File))

{Get-Disk | select Number, FriendlyName, PartitionStyle
}

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

3 answers

Sort by: Most helpful
  1. anil suthar 1 Reputation point
    2021-09-29T07:29:05.073+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

  2. Rich Matheisen 44,621 Reputation points
    2021-09-29T14:34:29.18+00:00

    Here's the same code sample I submitted to your earlier question on the same subject:

    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 don't know where you use the $LogDate variable so I omitted it in the example.

    Just import the CSV file into Excel.

    0 comments No comments

  3. Limitless Technology 39,336 Reputation points
    2021-10-04T10:26:36.657+00:00

    Hello Anilsuthar

    This cmdlet should help you,

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

    To create an output file: first you should select from the query:

    Select-Object PSComputerName, Number, PartitionStyle |

    And mark the export destination:
    Export-Csv c:\reports\disks-PartitionStyle.csv


    --If the reply is helpful, please Upvote and Accept as answer--

    0 comments No comments