Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows Powershell显示无法访问的驱动器的磁盘空间详细信息_Windows_Powershell - Fatal编程技术网

Windows Powershell显示无法访问的驱动器的磁盘空间详细信息

Windows Powershell显示无法访问的驱动器的磁盘空间详细信息,windows,powershell,Windows,Powershell,我尝试从另一台服务器B检索远程服务器a的磁盘空间详细信息,并使用以下PowerShell命令: Get-WmiObject -Class Win32_LogicalDisk -ComputerName aa.bb.cc.dd -filter "DriveType=3" | Select DeviceID,@{Name="Size(GB)";Expression={"{0:N1}" -f($_.size/1gb)}},@{Name="FreeSpace(GB)";Expression={"{0:N

我尝试从另一台服务器B检索远程服务器a的磁盘空间详细信息,并使用以下PowerShell命令:

Get-WmiObject -Class Win32_LogicalDisk -ComputerName aa.bb.cc.dd -filter "DriveType=3" | Select DeviceID,@{Name="Size(GB)";Expression={"{0:N1}" -f($_.size/1gb)}},@{Name="FreeSpace(GB)";Expression={"{0:N3}" -f($_.freespace/1gb)}}
结果如下:

DeviceID                   Size(GB)                   FreeSpace(GB)            
--------                   --------                   -------------            
C:                         59.9                       17.080                   
D:                         20.0                       0.875                    
F:                         100.0                      81.865
在服务器A中,驱动器D不可访问。我无法在计算机中查看驱动器空间详细信息。我检查了服务器A的磁盘管理中的驱动器空间详细信息,发现上面的值是正确的

我再次转到服务器A,并在其自己的PowerShell窗口中运行以下命令:

Get-WmiObject -Class Win32_LogicalDisk -filter "DriveType=3" | Select DeviceID,@{Name="Size(GB)";Expression={"{0:N1}" -f($_.size/1gb)}},@{Name="FreeSpace(GB)";Expression={"{0:N3}" -f($_.freespace/1gb)}} | out-file ./local.txt
现在我得到了以下输出:

DeviceID                   Size(GB)                   FreeSpace(GB)            
--------                   --------                   -------------            
C:                         59.9                       17.080                   
D:                         0.0                        0.000                    
F:                         100.0                      81.864 
实际上,这些命令几乎是相似的。唯一的区别是,如果我们试图获取远程机器的空间详细信息,那么我们需要添加参数-ComputerName和远程机器名称

我的问题是,为什么PowerShell在远程和本地运行命令时显示两种不同的结果

它显示的值实际上是正确的。 我有一个其他服务器的列表,并在脚本中使用此命令查找它们的磁盘空间详细信息。明天,如果其中一台服务器中的另一个驱动器无法访问,此命令将无法帮助我找到它,因为它也将检索其详细信息