如何才能获得有关没有驱动器号的驱动器的可用空间和其他信息?这些驱动器是在win 10工作站本地使用磁盘管理控制台安装在NTFS文件夹中的?我需要一个powershell的解决方案,有人能给我一个提示吗?
发布于 2021-08-29 17:46:22
这是一个非常棘手的问题!WMI命名空间Win32_MountPoint
包含我们所需的信息,用于查看哪些驱动器被挂载为磁盘驱动器或文件夹。
下面的条目是作为文件夹挂载的驱动器的示例。
#Use Get-WmiObject Win32_MountPoint if the below fails
PS> Get-CimInstance Win32_MountPoint
Directory : Win32_Directory (Name = "H:\")
Volume : Win32_Volume (DeviceID = "\\?\Volume{38569fb2-42e2-4359-8b42-1807...)
PSComputerName :
CimClass : root/cimv2:Win32_MountPoint
CimInstanceProperties : {Directory, Volume}
CimSystemProperties : Microsoft.Management.Infrastructure.CimSystemProperties
Directory : Win32_Directory (Name = "C:\thumb")
Volume : Win32_Volume (DeviceID = "\\?\Volume{e5d29a99-c6c2-11eb-b472-4ccc...)
PSComputerName :
CimClass : root/cimv2:Win32_MountPoint
CimInstanceProperties : {Directory, Volume}
CimSystemProperties : Microsoft.Management.Infrastructure.CimSystemProperties
有了这些信息,mind...we可以将DeviceID信息传递给另一个命令,以找出有多少磁盘空间。
get-volume | ? Path -eq $mount.Volume.DeviceID
DriveLetter FriendlyName FileSystemType DriveType HealthStatus OperationalStatus SizeRemaining Size
----------- ------------ -------------- --------- ------------ ----------------- ------------- ----
FAT32 Removable Warning Full Repair Needed 3.44 GB 3.74 GB
现在,让我们把它变成一个函数,在这个函数中,您传入挂载路径,然后返回实际磁盘上的信息。
Function Get-MountedFolderInfo{
param($MountPath)
$mount = gcim Win32_MountPoint | where directory -like "*$MountPath*"
if ($null -eq $mount){
return "no mounted file found at $MountPath"
}
$volumeInfo = get-volume | Where-Object Path -eq $mount.Volume.DeviceID
if ($null -eq $VolumeInfo){
"Could not retrieve info for:"
return $mount
}
$volumeInfo
}
Get-MountedFolderInfo -MountPath C:\thumb
DriveLetter FriendlyName FileSystemType DriveType HealthStatus OperationalStatus SizeRemaining Size
----------- ------------ -------------- --------- ------------ ----------------- ------------- ----
FAT32 Removable Warning Full Repair Needed 3.44 GB 3.74 GB
https://stackoverflow.com/questions/68975229
复制相似问题