将变量从Powershell传递给DISM

时间:2017-09-21 19:09:10

标签: powershell

我一直试图通过Powershell运行DISM但是我似乎在将一个变量从Powershell传递给DISM时遇到了问题。如果有更好的方法将我的驱动器号$ dl传递给DISM,我愿意接受建议。

$dl=(Mount-DiskImage -ImagePath "\\domain\shares$\IT\ISO\Desktops\Microsoft\SW_DVD5_WIN_EDU_10_1703_64BIT_English_MLF_X21-36554.ISO" -PassThru | Get-Volume).DriveLetter

RunAs /user:domain\svcaccount (Dism /online /enable-feature /featurename:NetFX3 /All /Source:{$dl}:\sources\sxs /LimitAccess)

1 个答案:

答案 0 :(得分:0)

将整个参数转换为单个字符串。

$dl = $dl + ':\sources\sxs'
RunAs /user:domain\svcaccount (Dism /online /enable-feature /featurename:NetFX3 /All /Source:$dl /LimitAccess)