我有一个通过Mount-DiskImage命令挂载的ISO。但是,我不知道如何获取已挂载的磁盘映像的驱动器号。我试着使用$mountResult = Mount-DiskImage D:\ISOs\clonezilla-live-1.2.12-10-i486.iso -PassThru。返回的信息都不是驱动器号,如下图所示:
PS C:\Windows\system32> $mountResult | fl *
Attached : False
BlockSize : 0
DevicePath :
FileSize : 110100480
ImagePath : D:\ISOs\clonezilla-live-1.2.12-10-i486.iso
LogicalSectorSize : 2048
Number :
Size : 110100480
StorageType : 1
PSComputerName :
CimClass : ROOT/Microsoft/Windows/Storage:MSFT_DiskImage
CimInstanceProperties : {Attached, BlockSize, DevicePath, FileSize...}
CimSystemProperties : Microsoft.Management.Infrastructure.CimSystemProperties
PS C:\Windows\system32> $mountResult | select -ExpandProperty CimSystemProperties | fl *
Namespace : ROOT/Microsoft/Windows/Storage
ServerName : ECHO-BASE
ClassName : MSFT_DiskImage
Path : 之后调用Get-DiskImage D:\ISOs\clonezilla-live-1.2.12-10-i486.iso也不会返回驱动器号。
如何获取驱动器号?
发布于 2013-12-19 06:26:15
我发现这个很管用
$beforeMount = (Get-Volume).DriveLetter
$mountResult = Mount-DiskImage $imagePath
$setuppath = (compare $beforeMount (Get-Volume).DriveLetter -PassThru) + ":\"发布于 2016-11-16 02:57:15
仅供参考,我再次挂载相同的映像时遇到问题,所以我做了一个小更改,如果未挂载,则检查映像是否已挂载,并提供卷。
$ImagePath= " " ## Path of ISO image to be mounted
$ISODrive = (Get-DiskImage -ImagePath $ImagePath | Get-Volume).DriveLetter
IF (!$ISODrive) {
Mount-DiskImage -ImagePath $ImagePath -StorageType ISO
}
$ISODrive = (Get-DiskImage -ImagePath $ImagePath | Get-Volume).DriveLetter
Write-Host ("ISO Drive is " + $ISODrive)发布于 2019-04-12 15:27:06
嗯..。为什么这么复杂?
Mount-DiskImage D:\cd.iso -PassThru | Get-Volumehttps://stackoverflow.com/questions/16452901
复制相似问题