首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >通过Powershell安装带有驱动器字母的ISO

通过Powershell安装带有驱动器字母的ISO
EN

Stack Overflow用户
提问于 2020-05-01 01:03:28
回答 2查看 1.9K关注 0票数 1

我正在尝试安装一个ISO,我想联系一个驱动器的字母与该安装。我想指定驱动器字母为Y:\以下不工作,谁能帮我。谢谢

代码语言:javascript
复制
#Variable Declaration
$isoImg = "P:\Software\Windows10CurrentVersion\Windows10.iso"

#Mount ISO and Gather Drive Letter
Mount-DiskImage -ImagePath $isoImg -PassThru | Out-Null

#Obtain Drive Letter
$driveletter = (Get-DiskImage $isoImg | Get-Volume).DriveLetter
EN

回答 2

Stack Overflow用户

发布于 2020-05-01 10:55:31

您可以挂载ISO并接受(目前)自动分配的驱动器号。以后可以更改它,但是您需要作为管理员运行它:

代码语言:javascript
复制
# the full path to the ISO file
$isoPath = "P:\Software\Windows10CurrentVersion\Windows10.iso"

# mount the ISO, but first check if it is already mounted
$isoDrive = Get-DiskImage -ImagePath $isoPath
if (!$isoDrive) {
    $isoDrive = Mount-DiskImage -ImagePath $isoPath -PassThru
}
# $isoDrive is a Microsoft.Management.Infrastructure.CimInstance#ROOT/Microsoft/Windows/Storage/MSFT_DiskImage

# get the DriveLetter currently assigned to the drive (a single [char])
$isoLetter = ($isoDrive | Get-Volume).DriveLetter

为这个驱动器重命名驱动程序。

此部分需要作为管理员运行

代码语言:javascript
复制
# find the volume by its automatically assigned driveletter and set the new drive letter
$drive = Get-WmiObject Win32_Volume -Filter ('DriveLetter = "{0}:"' -f $isoLetter)
$drive.DriveLetter = 'Y:'
$null = $drive.Put()

若要卸下iso驱动器:

代码语言:javascript
复制
$isoDrive | Dismount-DiskImage | Out-Null

希望这有帮助

票数 2
EN

Stack Overflow用户

发布于 2022-09-17 20:47:17

您可以挂载ISO映像,然后像下面这样分配驱动器号:

代码语言:javascript
复制
# ISO image - replace with path to ISO to be mounted
$isoImg = "P:\Software\Windows10CurrentVersion\Windows10.iso"

# Drive letter - use the required drive letter instead of Y:
$driveLetter = "Y:"

# Mount the ISO, without having a drive letter auto-assigned
$diskImg = Mount-DiskImage -ImagePath $isoImg -NoDriveLetter

# Get mounted ISO volume
$volInfo = $diskImg | Get-Disk | Get-Partition | Get-Volume

# Mount volume with specified drive letter (requires Administrator access)
mountvol $driveLetter $volInfo.UniqueId
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61535306

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档