I found a working code here: how-to-get-output-in-gb-instead-of-b
I'm trying to figure out what am I doing wrong & if it could be done this way...
$diskInfo = Get-CimInstance win32_logicaldisk | Select DeviceID, Size, FreeSpace
$diskInfo | foreach-object {
$computername = "$env:computername"
$driveLetter = $($_.DeviceID)
$totalSize = $([math]::round(($_.size /1gb),2))
$sizeLeft = $([math]::round(($_.freeSpace /1gb),2))
$diskInfo | ConvertTo-Csv -NoTypeInformation
}
I'm getting the following:
"DeviceID","Size","FreeSpace"
"C:","127389396992","4291960832"
Hoping to get:
"ComputerName","C:","118.64","50" & be able to export it to CSV...
ty