无法使用PowerShell安装ISO映像文件


-2
PS F:\ISOs\System>  [System.Environment]::OSVersion.Version



Major  Minor  Build  Revision
-----  -----  -----  --------
10     0      14393  0

PS F:\ISOs\System> dir


Directory: F:\ISOs\System


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
...
-a----        11/1/2013     13:32      134971392 Win7PE2.iso
...

PS F:\ISOs\System> Mount-DiskImage -ImagePath .\Win7PE2.iso -Verbose
Mount-DiskImage : The system cannot find the file specified.
At line:1 char:1
+ Mount-DiskImage -ImagePath .\Win7PE2.iso -Verbose
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (MSFT_DiskImage:ROOT/Microsoft/.../MSFT_DiskImage) [Mount-DiskImage], CimException
+ FullyQualifiedErrorId : HRESULT 0x80070002,Mount-DiskImage

如何解决这个问题呢?


你的问题是什么?

如何解决这个问题呢?谢谢。
TRX 2016年

Answers:


3

您需要指定.ISO文件的完整路径。

例如:

Mount-DiskImage -ImagePath 'F:\ISOs\System\Win7PE2.iso' -Verbose

从Microsoft的Mount-DiskImage TechNet条目Get-Help Mount-DiskImagePowerShell中:

此cmdlet需要VHD或ISO文件的完整路径。


哦,我,我不知道为什么我没注意到这一点。非常感谢你!
TRX 2016年

谢谢!但是,这是一个非常奇怪的限制和愚蠢的错误信息。
AsbjørnUlsberg18年5

1

如果您想在脚本中使用它,或者您懒得输入完整路径(就像我一样),您可以使用:

Mount-DiskImage ((Get-Item -Path ".\" -Verbose).FullName+"\ISONAME.iso")

我没有看到这个脚本的重点:你为什么要使用Get-Item,然后,稍后,自己指定ISO的名称?沿东西$a = @(Get-ChildItem -Include *.iso) | Select-Item -ExpandProperties FullName; Mount-DiskImage -ImagePath $a[0] -Verbose会显得更加精细的给我。
flolilo于
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.