Convert PowerShell output from bytes to GB {Get-PhysicalDisk}

~OSD~ 2,201 Reputation points
2023-01-15T22:39:25.0733333+00:00

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?

User's image

#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
Windows for business | Windows Client for IT Pros | User experience | Other
0 comments No comments
{count} votes

Answer accepted by question author
  1. Castorix31 91,506 Reputation points
    2023-01-15T23:05:27.2333333+00:00

    You can see the answer from this thread : Disk size and Free space in GB using Power shell


1 additional answer

Sort by: Most helpful
  1. ~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
    
    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.