运行 Add-WindowsFeature 时发生以下错误:
PS C:\Users\pornograph> Add-WindowsFeature -Name "DSC-Service" -IncludeAllSubFeature -ErrorVariable errorVar
Add-WindowsFeature : The request to list features available on the specified server failed.
A DISM session could not be opened.
An error occurred. The directory in the temporary folder D:\TEMP\ could not be created.
Ensure that the path to the temporary folder exists and that you have Read/Write permissions on the folder. Error:
0x80070003
At line:1 char:1
+ Add-WindowsFeature -Name "DSC-Service" -IncludeAllSubFeature -ErrorVariable erro ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (@{Vhd=; Credent...Name=localhost}:PSObject) [Install-WindowsFeature],DeploymentProviderException
+ FullyQualifiedErrorId : DISMAPI_Error__Failed_Opening_Dism_Session,Microsoft.Windows.ServerManager.Commands.AddWindowsFeatureCommand
从哪里來D:\TEMP\
?
- 服务器没有 D:
- 没有以 D 开头的环境变量:
- 机器
TEMP
和TMP
=E:\TEMP
- 用户和进程
TEMP
和TMP
=C:\Users\etc.
- 机器
- 操作系统 = Win 2012 R2 标准 x64
- $psversion表.psversion =
4 0 -1 -1
答案1
(对原始问题的编辑似乎陷入了困境,因此再次发布:)
更新:它似乎在注册表中(很可能是在原始服务器映像中设置的):
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-PowerShell-DSC-PullServer-Package~31bf3856ad364e35~amd64~en-US~6.3.9600.16384
InstallLocation
="\\?\D:\temp\Dism\IDASF2ZC\{GUID}\"
整个HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing
树由 TrustedInstaller 拥有(所有其他树 = 只读)。授予写入权限并更改值似乎没有带来任何变化(D:\TEMP
仍在使用) - 是否需要重新启动某些东西才能读取新值?
不幸的是,以管理员身份运行不是一个选项。