eck*_*kes 6 windows powershell disk-image
当我挂载 ISO 文件时,例如C:\temp\demo.iso
在 Windows 10 和/或 Windows Server(或 powershell 命令)上双击它,Mount-DiskImage
我可以看到新磁盘(在本例中它返回一个新驱动器I:
):
Get-Volume I | fc
class CimInstance#ROOT/Microsoft/Windows/Storage/MSFT_Volume
{
ObjectId = {1}\\HOST01\root/Microsoft/Windows/Storage/Providers_v2\WSP_Volume.ObjectId="{de774a20-4e16-11e8-ad1
e-806e6f6e6963}:VO:\\?\Volume{354097cd-6bd5-11e7-a5d9-aaaaa99b2b5d}\"
PassThroughClass =
PassThroughIds =
PassThroughNamespace =
PassThroughServer =
UniqueId = \\?\Volume{354097cd-6bd5-11e7-a5d9-aaaaa99b2b5d}\
AllocationUnitSize = 2048
DedupMode = NotAvailable
DriveLetter = I
DriveType = CD-ROM
FileSystem = CDFS
FileSystemLabel = 20190306-134242
FileSystemType = Unknown
HealthStatus = Healthy
OperationalStatus = OK
Path = \\?\Volume{354097cd-6bd5-11e7-a5d9-aaaaa99b2b5d}\
Size = 2136489984
SizeRemaining = 0
PSComputerName =
}
Run Code Online (Sandbox Code Playgroud)
但我看不到c:\temp\demo.iso
该磁盘的图像源文件路径( )是什么。mount-diskimage
返回此信息作为结果对象,但事后或使用资源管理器安装时我可以在哪里获取它?我需要用 powershell 编写脚本。
如果您知道 DevicePath 那么
Get-DiskImage -DevicePath \\.\CDROM0
Run Code Online (Sandbox Code Playgroud)
如果您只知道驱动器盘符,请尝试(您需要从路径中删除末尾的“\”)
Get-Volume -DriveLetter I | % { Get-DiskImage -DevicePath $($_.Path -replace "\\$")}
Run Code Online (Sandbox Code Playgroud)
结果示例:
Attached : True
DevicePath : \\.\CDROM1
FileSize : 2494107648
ImagePath : C:\temp\demo.iso
LogicalSectorSize : 2048
...
Run Code Online (Sandbox Code Playgroud)