question

anilsuthar-9204 avatar image
0 Votes"
anilsuthar-9204 asked LimitlessTechnology-2700 answered

How to get partition style from multiple servers using powershell

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
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

anilsuthar-9204 avatar image
0 Votes"
anilsuthar-9204 answered

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
}

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

RichMatheisen-8856 avatar image
0 Votes"
RichMatheisen-8856 answered

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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

LimitlessTechnology-2700 avatar image
0 Votes"
LimitlessTechnology-2700 answered

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--

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.