Here is the result without hash tables:复制代码
- $Freespace =
- @{
- Expression = {[int]($_.Freespace/1GB)}
- Name = 'Free Space (GB)'
- }
- $PercentFree =
- @{
- Expression = {[int]($_.Freespace*100/$_.Size)}
- Name = 'Free (%)'
- }
- Get-WmiObject -Class Win32_LogicalDisk | Select-Object -Property DeviceID, VolumeName, $Freespace, $PercentFree
PS C:\> Get-WmiObject -Class Win32_LogicalDisk | Select-Object -Property DeviceID, VolumeName, Freespace DeviceID VolumeName Freespace -------- ---------- --------- C: BatHome 114592428032 |
PS C:\> Get-WmiObject -Class Win32_LogicalDisk | Select-Object -Property DeviceID, VolumeName, $Freespace, $PercentFree DeviceID VolumeName Free Space (GB) Free (%) -------- ---------- --------------- -------- C: BatHome 107 45 |
欢迎光临 批处理之家 (http://bbs.bathome.net/) | Powered by Discuz! 7.2 |