You can see the answer from this thread : Disk size and Free space in GB using Power shell
Convert PowerShell output from bytes to GB {Get-PhysicalDisk}
~OSD~
2,201
Reputation points
Hi,
I am using PS to get Disk detail and save the out put in an HTML file (see below).
The SIZE attribute displays the size in bytes, while I prefer to have this in GB. Is there a way to get the value of size in GB instead of bytes?
#Disk Details
$props = "Number", "FriendlyName", "MediaType", "SerialNumber", "OperationalStatus", "HealthStatus","Size"
Get-PhysicalDisk -ErrorAction SilentlyContinue |Select-Object $props |ConvertTo-Html |Out-File D:\DemoFolder\Disk.html
Windows for business Windows Server User experience Other
20,212 questions
Windows for business Windows Client for IT Pros User experience Other
Accepted answer
1 additional answer
Sort by: Most helpful
-
~OSD~ 2,201 Reputation points
2023-01-17T21:13:16.4966667+00:00 Adapted to your linked suggestion, but here I have a blank HTML file.
Is it possible to get save the output as HTML file and convert the "Size" into GB(s) for the following :
Get-PhysicalDisk
Get-Partition
Get-Volume
Get-WmiObject -Class Win32_LogicalDisk -ComputerName LOCALHOST | ? {$_. DriveType -eq 3} | select DeviceID, {$_.Size /1GB}, {$_.FreeSpace /1GB} ConvertTo-Html|Out-File D:\DemoFolder\Partition.html