mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-30 20:59:12 +08:00
f10c49281a
* [vcpkg] Add disk space report to PR/CI Example output: ``` Disk Label Size Free Space ---- ----- ---- ---------- C: Sabrent 1907 GiB 1239 GiB D: Dev 447 GiB 383 GiB E: Samsung 960 Pro 1908 GiB 1084 GiB H: Rocket 3815 GiB 863 GiB R: 0 B 0 B S: 0 B 0 B ```
36 lines
900 B
PowerShell
36 lines
900 B
PowerShell
# Copyright (c) Microsoft Corporation.
|
|
# SPDX-License-Identifier: MIT
|
|
#
|
|
|
|
<#
|
|
.SYNOPSIS
|
|
Prints total and free disk space for each disk on the system
|
|
#>
|
|
|
|
Function Format-Size {
|
|
[CmdletBinding()]
|
|
Param([long]$Size)
|
|
|
|
if ($Size -lt 1024) {
|
|
$Size = [int]$Size
|
|
return "$Size B"
|
|
}
|
|
|
|
$Size = $Size / 1024
|
|
if ($Size -lt 1024) {
|
|
$Size = [int]$Size
|
|
return "$Size KiB"
|
|
}
|
|
|
|
$Size = $Size / 1024
|
|
if ($Size -lt 1024) {
|
|
$Size = [int]$Size
|
|
return "$Size MiB"
|
|
}
|
|
|
|
$Size = [int]($Size / 1024)
|
|
return "$Size GiB"
|
|
}
|
|
|
|
Get-CimInstance -ClassName Win32_LogicalDisk | Format-Table -Property @{Label="Disk"; Expression={ $_.DeviceID }},@{Label="Label"; Expression={ $_.VolumeName }},@{Label="Size"; Expression={ Format-Size($_.Size) }},@{Label="Free Space"; Expression={ Format-Size($_.FreeSpace) }}
|