Disks and Partitions Management with Windows PowerShell
In this article we will learn how to print the disk information and partition information using the window feature PowerShell or command line by PowerShell.
Using the PowerShell we can perform or manage all the local disk and partition same like Window Disk Management ( GUI - diskmgmt.msc )
Who to Open PowerShell ?
To Open PowerShell, Go to Search and type PowerShell See the below screenshot
Window Search ==> Windows PowerShell ==> Run as Administrator
Note: you can open without administrator if tasks do not need any administrator privileges
How to Print Disk ?
We can print all the attached disk using the below command of PowerShell
- Get-PhysicalDisk
- diskpart
1 - Get-PhysicalDisk
To print the physical disks characteristics nd status we can use this "Get-PhysicalDisk" cmdlet
PS C:\> Get-PhysicalDisk
Number FriendlyName SerialNumber MediaType CanPool OperationalStatus HealthStatus Usage Size
------ ------------ ------------ --------- ------- ----------------- ------------ ----- ----
1 TOSHIBA MQ01ABD100 168DS1xxx HDD False OK Healthy Auto-Select 931.51 GB
0 Speed Star AA0000000000xxx SSD False OK Healthy Auto-Select 119.24 GB
2 - Diskpart
Using the diskpart cmdlet we can also print the disk
PS C:\> diskpart
DISKPART> list disk
How to Print the Disk Partition Using PowerShell ?
- diskpart
- Get-Partation
1 - diskpart
To print all the partition of disk
diskpart ==> list disk ==> select disk <disk Number from ### ) ==> list partition
We print the disk details on above diskpart commnd, in the list disk command output we can see the disk number in ### colom.
We have add the disk number with select disk command for disk selection here i will select 1st disk
and then type list partition for printing all the partitions
PS C:\> diskpart
DISKPART> list disk
DISKPART> select disk 0
DISKPART> list partition
To print the all the partitions we can use Get-Partition
PS C:\> Get-Partition
To Print particular disk partition
PS C:\> Get-Partition -DiskNumber 0
Thanks you !!
I hope this topic gave you all the information you needed. If you have any further questions or would like more detailed directions feel free to contact us using any of the following sources.We look forward to talking to you.