How can I use Install-WindowsFeature with the source parameter

5.5k views Asked by At

I'm trying to get this to work

Install-WindowsFeature NET-Framework-Core -source \\unc\blah\software\

I'm specifying a path that directly contains dotnetfx35.exe and I've tried specifying the path to the file and to the containing folder but neither works. I suspect there is some kind of folder structure I need to put in place but I can't find any documentation. This might be better on Server Fault but since I'm trying to install a framework using code I thought I'd try here first

1

There are 1 answers

2
briantist On BEST ANSWER

You can't give it an installer .exe file; that's not how this cmdlet works. It's looking for files in the side by side (SxS) of the local computer first. The path you give it has to be to a similar SxS store. You can also mount a WIM and point it at that.

From Install-WindowsFeature on MSDN:

-Source<String[]>
Specifies the path to feature files, if the files are not available in the local feature store of the target computer or VHD. Valid values for this parameter are either a network path or the path to a Windows image file (WIM). If you are installing roles or features on an offline VHD, you must use a mounted WIM. It is not necessary to mount the WIM file for installing on a running physical computer, because a WIM is mounted internally for deployments to a physical computer. Specify the path by using a local relative path, or by using built-in environment variables that are prefixed with the $env tag as shown in the following examples.

The path specified in this parameter is only used if the command cannot find feature files in the local side-by-side store of the specified target computer or VHD. The command searches for feature files in the following order:

1) On the target computer or offline VHD.
2) Path specified as the value of this parameter. If you add a UNC path, verify that the computer account of the target server has Read permissions on the share. The computer account should be in one of the following formats: DOMAIN\SERVERNAME$ or SERVER$
3) Repository path specified by the Group Policy Object (GPO), Specify settings for optional component installation and component repair, located in Computer Configuration/Administrative Templates/System in Local Group Policy Editor. This Group Policy setting controls the following Windows Registry setting: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\Servicing\LocalSourcePath.
4) Windows Update.

Personally, I don't think it's worth hosting this somewhere internally. If you're using WSUS and are trying to workaround the problem where client machines try to download dot net 3.5 from WSUS (where it doesn't exist), then I recommend using group policy to set the policy listed above in 3) to allow clients to download .NET 3.5 directly from Windows Update. That has been working fine for me.