PowerShell for Admins

Using Install-WindowsFeature with Offline Source

Don Jones
2 min read
Share:

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.

Related Articles

Sep 15, 2023

PowerShell Escape Room

PowerShell Escape Room by Michiel Hamers by Michiel Hamers https://about.me/michielhamers/ Why on earth you want to create an Escape Room with PowerShell as backend? I’ve always been a fan of escape rooms, so I decided to create my own for my kids. I wanted to make it something that would be challenging and fun for them, but also educational. I decided to use PowerShell as the backend for the escape room, as I’m a PowerShell developer and I thought it would be a great way to learn more about the language.

Sep 15, 2023

Microsoft Graph PowerShell Module: Getting Started Guide

Microsoft Graph PowerShell Module: Getting Started Guide by Jeff Brown Microsoft is retiring the Azure AD Graph API sometime after June 30, 2023 (announcement). This retirement includes the Azure AD PowerShell module. In its place, Microsoft has released the Microsoft Graph PowerShell module. The Microsoft Graph PowerShell module is the next-generation way of managing Microsoft cloud services using PowerShell. If you have used MSOnline or Azure AD PowerShell in the past, you’ll need to read on to learn about this new module.

Oct 8, 2021

ICYMI: PowerShell Week of 08-October-2021

Topics include VMWare, Windows 11, Web Reports and more… Special thanks to Robin Dadswell, Prasoon Karunan V, Kiran Patnayakuni and Kevin Laux How to gather your vCenter inventory data with this VMware PowerShell script by Scott Matteson on 7th October Inventory reports are a common request when administering a VMware vCenter environment. Learn how this VMware PowerShell script can make such requests quick and easy Building a Web Report in PowerShell, use the -Force Luke by Chris Noring on 8th October