Created
August 13, 2023 06:54
-
-
Save KentaGoto/d861b05798963a6659f6d296a671bbda to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ドライブの使用状況を取得する | |
$diskUsage = Get-WmiObject Win32_LogicalDisk | Where-Object { $_.DriveType -eq 3 } | ForEach-Object { | |
[PSCustomObject]@{ | |
'Drive' = $_.DeviceID | |
'UsedSpaceGB' = [math]::Round((($_.Size - $_.FreeSpace) / 1GB), 2) | |
'FreeSpaceGB' = [math]::Round(($_.FreeSpace / 1GB), 2) | |
'TotalSpaceGB' = [math]::Round(($_.Size / 1GB), 2) | |
} | |
} | |
# Out-GridView で結果を表示する | |
$diskUsage | Out-GridView -Title "Disk Usage" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment