c# - 如何将挂载点的 Volume GUID 转换为实际路径?

标签 c# windows powershell failovercluster

我正在使用此代码获取 Path、VolumeLabel、TotalSize、FreeSpace:

gwmi -ComputerName $ComputerName -namespace root\MSCluster MSCluster_DiskPartition -Credential $cred -Authentication PacketPrivacy | Format-Table Path, VolumeLabel, TotalSize, FreeSpace -AutoSize

输出:

Path                                             VolumeLabel TotalSize FreeSpace
----                                             ----------- --------- ---------
U:                                               Archive1      4194184    379651
\\?\Volume{76795fb2-254e-454d-a95a-739018690cf4} Archive3      4194184    524883
X:                                               Archive2      4194184    735366
\\?\Volume{57e93910-60f9-44b9-8d9d-29d506e1e3d7} Archive4      4194184   1483274

我如何从卷 GUID 获取安装点的真实路径(或者可能是驱动器名称)?

enter image description here

我尝试使用 .GetRelated 类但没有成功。有人可以帮我解决这个问题吗?

最佳答案

我确实使用安装在 C:\test_vhd\ 的 vhd 文件对其进行了测试。它似乎有效。

Get-WmiObject -class Win32_Volume -computername localhost | 
    ? { $PSItem.DeviceID.Contains("f91957ea-bb2f-11e4-9464-028037ec0200") } |
    Select-Object Name

    Name
    ----
    C:\test_vhd\

enter image description here

关于c# - 如何将挂载点的 Volume GUID 转换为实际路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28608540/

相关文章:

session - Powershell脚本杀死.exe终端服务器断开的 session

c# - 如何在 C# 中解码 utf 字符串

c# - 构建 View 模型的代码应该放在哪里?

c# - .NET TCP 服务器删除连接

java - mac 中的 processWindowEvent

windows - 如何使用NSIS向 "Open With"菜单添加程序

c# - 如何测试给定的功能代码单元 (C#) 是否不创建/写入任何文件到磁盘?

c# - 未找到 BackgroundWorker

regex - 在 Powershell 中使用正则表达式匹配 $$

unix - PowerShell 是否已准备好替换 Windows 上的 Cygwin shell?