question

DnyaneshwarSurywanshi-3200 avatar image
0 Votes"
DnyaneshwarSurywanshi-3200 asked ·

PowerShell Script for show Virtual Machine Drive details like DiskName, DriveLetter, Size and FileSystem

I want to show the VM Machine Drive details using powershell script so if anyone have please share with me or give me any reference.

azure-virtual-machineswindows-server-powershell
10 |1000 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.

Monalla-MSFT avatar image
0 Votes"
Monalla-MSFT answered ·

@DnyaneshwarSurywanshi-3200 - Thanks for reaching out.

If your VM runs in Azure, Get-AzDisk would retrieve information about the underlying disk.

Here is the doc info for that- Get-AzDisk PowerShell Script

If the above response was helpful, please feel free to "Accept as Answer" , so it can be beneficial to the community.


· 1 ·
10 |1000 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.

@Monalla I already gone through this but not work for me I want VM drive details like C drive , D , F and their file system name.

0 Votes 0 ·
DnyaneshwarSurywanshi-3200 avatar image
0 Votes"
DnyaneshwarSurywanshi-3200 answered ·

@Monalla-MSFT Below is my script to get Drive details of azure VM so I want to run this from my Local server machine .

Get-WmiObject Win32_DiskDrive | ForEach-Object {
$disk = $
$partitions = "ASSOCIATORS OF " +
"{Win32_DiskDrive.DeviceID='$($disk.DeviceID)'} " +
"WHERE AssocClass = Win32_DiskDriveToDiskPartition"
Get-WmiObject -Query $partitions | ForEach-Object {
$partition = $

$drives = "ASSOCIATORS OF " +
"{Win32_DiskPartition.DeviceID='$($partition.DeviceID)'} " +
"WHERE AssocClass = Win32_LogicalDiskToPartition"
Get-WmiObject -Query $drives | ForEach-Object {
New-Object -Type PSCustomObject -Property @{
DriveLetter = $.DeviceID
VolumeName = $
.VolumeName
Size = '{0:d} GB' -f [int]($.Size / 1GB)
FreeSpace = '{0:d} GB' -f [int]($
.FreeSpace / 1GB)
}
}
}
}

Please let me know any idea or information about how i can get from loacal.

·
10 |1000 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.

Monalla-MSFT avatar image
0 Votes"
Monalla-MSFT answered ·

@DnyaneshwarSurywanshi-3200 - Thanks for providing more details.

If you would like to run this from your local server Machine and If you are using a modern Windows system then you could try the below commands :

Get-PhysicalDisk,

Get-Disk

Get-Partition

depending on the specific properties you are looking for. WMI is the older way of doing it, but it's more compatible with older systems and still works with modern ones.


Drive letters are associated with partitions, not physical disks so you can try using Get-Partition for that.

If you're looking for properties associated with the physical disk, you can try using Get-PhysicalDisk for that.


Please feel free to "Accept as Answer" if the response was helpful.






· 4 ·
10 |1000 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.

@Monalla-MSFT Thank you for the reply I am attaching the image so there are two disk i.e Disk 0 and Disk 1
from Disk 0 there are two drive one is Windows C and another is System Reserved and from Disk 1 there is Temporary D so I want Drive details based on Disk . Like Dive Name, DriveLetter , Size and FreeSpace 62632-diskmanagement.png





0 Votes 0 ·
diskmanagement.png (54.9 KiB)
Monalla-MSFT avatar image Monalla-MSFT DnyaneshwarSurywanshi-3200 ·

Thank you for sharing the info.

I am working with the internal team here, and I will get back to you as soon as I have an update.

0 Votes 0 ·

Thank you for the comment. Sure I will wait for your update.

0 Votes 0 ·
Show more comments