如何获取远程计算机的磁盘容量和可用空间 [英] How to get disk capacity and free space of remote computer

查看:91
本文介绍了如何获取远程计算机的磁盘容量和可用空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个单衬:

get-WmiObject win32_logicaldisk -Computername remotecomputer

输出是这样的:

DeviceID     : A:
DriveType    : 2
ProviderName :
FreeSpace    :
Size         :
VolumeName   :

DeviceID     : C:
DriveType    : 3
ProviderName :
FreeSpace    : 20116508672
Size         : 42842714112
VolumeName   :

DeviceID     : D:
DriveType    : 5
ProviderName :
FreeSpace    :
Size         :
VolumeName   :

如何获取DeviceID C:FreespaceSize?我只需要提取这两个值而不需要其他信息.我已经用 Select cmdlet 试过了,但没有效果.

How do I get Freespace and Size of DeviceID C:? I need to extract just these two values with no other informations. I have tried it with Select cmdlet, but with no effect.

我只需要提取数值并将它们存储在变量中.

I need to extract the numerical values only and store them in variables.

推荐答案

$disk = Get-WmiObject Win32_LogicalDisk -ComputerName remotecomputer -Filter "DeviceID='C:'" |
Select-Object Size,FreeSpace

$disk.Size
$disk.FreeSpace

仅提取值并将它们分配给变量:

To extract the values only and assign them to a variable:

$disk = Get-WmiObject Win32_LogicalDisk -ComputerName remotecomputer -Filter "DeviceID='C:'" |
Foreach-Object {$_.Size,$_.FreeSpace}

这篇关于如何获取远程计算机的磁盘容量和可用空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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