Add-WindowsFeature fails with unexpected path


The following error is occurring running 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:
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

Where is D:\TEMP\ coming from?

  • Server has no D:
  • No environment variable starts with D:
    • Machine TEMP and TMP = E:\TEMP
    • User and Process TEMP and TMP = C:\Users\etc.
  • OS = Win 2012 R2 Standard x64
  • $psversiontable.psversion = 4 0 -1 -1
asked on Server Fault Jan 17, 2018 by aws4rtc

1 Answer


(Edit to original question seems to be stuck in moderation, so here it is again:)

UPDATE: It appears to be in the registry (most likely set in the original server image):

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}\"

The entire HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing tree is owned by TrustedInstaller (all others = read only). Granting write and changing the value seemed to make no change (D:\TEMP still being used) - does something need to be restarted for the new value to be read?

Running as admin is not an option unfortunately.

answered on Server Fault Jan 23, 2018 by aws4rtc

User contributions licensed under CC BY-SA 3.0