Powershell 3.0:替代“Get-Volume" [英] Powershell 3.0 : Alternative to "Get-Volume"

查看:26
本文介绍了Powershell 3.0:替代“Get-Volume"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试获取计算机上每个硬盘卷的各种属性.

I'm trying to get various properties for each hdd-volume on the computer.

我使用的是 cmdlet get-volume 然后通过 foreach 遍历它,但该 cmdlet 在 Windows Server 2008 中不存在.:(

I was using the cmdlet get-volume and then walking through it via foreach, but that cmdlet does not exist in Windows Server 2008. :(

有人知道替代方案吗?

我只需要驱动器号、objectId/guid、可用空间、总空间和每个卷的名称.

I just need the drive letter, objectId/guid, free space, total space, and the name of each volume.

推荐答案

WMI 类 Win32_Volume 有你要找的信息

The WMI class Win32_Volume has the information you are looking for

Get-WMIObject -Class Win32_Volume | Select DriveLetter,FreeSpace,Capacity,DeviceID,Label

花哨的步法可以让驱动器空间属性看起来更吸引人.

Which a little fancy footwork you can make the drive space properties looking a little more appealing.

Get-WmiObject -Class Win32_Volume | 
        Select DriveLetter,
            @{Label="FreeSpace (In GB)";Expression={$_.Freespace/1gb}},
            @{Label="Capacity (In GB)";Expression={$_.Capacity/1gb}},
            DeviceID,Label |
        Format-Table -AutoSize

这篇关于Powershell 3.0:替代“Get-Volume"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆