Using Install-WindowsFeature with Offline Source

As you probably know, the Install-WindowsFeature (used to be Add-WindowsFeature; that's now an alias to Install-) can add Windows roles and features from PowerShell. If your server doesn't have the installer source on the local disk, then the cmdlet will default to grabbing it from Windows Update - a pain for disconnected servers. Install-WindowsFeature does offer a means of using an alternate local source (like a DVD or file server location), but using it can be a bit hinky.

The cmdlet help indicates that you should point to a Windows image (WIM) file. That'll work, but you can't just provide the path of the WIM. You also need to put a wim:/ prefix on the front of the path, and a suffix that tells the thing which edition of Windows you're working with, so that it grabs the right bits. For example, wim:/d:/sources/install.wim:4. That "4" is the suffix for Datacenter Edition, telling the installer to look at index 4 within the WIM for the necessary feature.

  • 1 is Standard Edition Server Core
  • 2 is Standard Edition
  • 3 is Datacenter Edition Server Core
  • 4 is Datacenter Edition

Wanted to post this, as there isn't a good example in the docs.

UPDATE: I've bugged this in Connect if you'd like to vote it up, so that the team gains sight of it and can have an opportunity to expand the docs.

About the Author

Don Jones

Profile photo of Don Jones

Don Jones is a Windows PowerShell MVP, author of several Windows PowerShell books (and other IT books), Co-founder and President/CEO of PowerShell.org, PowerShell columnist for Microsoft TechNet Magazine, PowerShell educator, and designer/author of several Windows PowerShell courses (including Microsoft's). Power to the shell!

3 Comments

  1. If you have a server configured to point at a WSUS server the -sources parameter does not work, full stop. It took me 2 days to find this out when trying to install the GUI on a server core installation.

    • Hadn't run into that but I suppose it makes a degree of sense. The organizational-level configuration - e.g., "we use WSUS" - could be a desired override for the individual administrator. Inconvenient if you're him, but I could see folks not wanting the org-level config overridden. Again, should be doc'd.

Leave a Reply

Your email address will not be published. Required fields are marked *