Skip to content

niklasrst/windows-mediacreation-cli

Repository files navigation

🪟 A Media Creation Tool CLI 🪟

This repo contains my solution of a media creation tool to create Windows Installation media using PowerShell.

GitHub Downloads (all assets, all releases)

🛈 HINT
If you want to use the script, grab the latest release as the script version in the code is work-in-progress.

Introduction

I´ve created this script as I wanted to automate the creation of usb-drives with Windows installation media. So I came up with the idea to create a parameter based PowerShell script to ask for the needed details and then fully automated create a usb-drive, containing the Windows installation media. It currently supports Windows 10 in 22H2 and Windows 11 from 22H2 up to 25H2.

How to use it?

USB Installation media

Use this command to run the script with the minimal required set of parameters to create a usb-based installation media.

# Minimal parameter setup
.\mctcli.ps1 -Windows 11 -Architecture amd64 -Build 25H2 -LanguageCode "en-us" -RegionCode "en-us" -Edition Pro -UsbDriveLetter "E:"

# Maximal parameter setup to inject a oem driver pack
.\mctcli.ps1 -Windows 11 -Architecture amd64 -Build 25H2 -LanguageCode "en-us" -RegionCode "en-us" -Edition Pro -UsbDriveLetter "E:" -DriverManufacturer Dell -DriverModel "Latitude 5450" -DriverInjectionType DISM -Verbose

Currently the mctcli.ps1 script only supports to download one oem enterprise driver pack.

Single Driver adding

If you need to add another driver, use the add-drivers.ps1 script like this

.\add-driver.ps1 -Architecture amd64 -UsbDriveLetter "E:" -DriverManufacturer Dell -DriverModel "Latitude-7450" -DriverInjectionType DISM

Multi Driver adding

If you need to add more drivers, use the add-multi-drivers.ps1 script like this

.\add-multi-driver.ps1 -Architecture amd64 -UsbDriveLetter "E:" -DriverManufacturer Dell -DriverModel "Latitude-5440","Latitude-5450" -DriverInjectionType DISM

ISO Installation media

Use this command to run the script with the minimal required set of parameters to create a ISO-based installation media.

# Minimal parameter setup
.\mctiso.ps1 -Windows 11 -Architecture amd64 -Build 25H2 -LanguageCode "en-us" -RegionCode "en-us" -Edition Pro

# Maximal parameter setup to inject a oem driver pack
.\mctiso.ps1 -Windows 11 -Architecture amd64 -Build 25H2 -LanguageCode "en-us" -RegionCode "en-us" -Edition Pro -DriverManufacturer Dell -DriverModel "Latitude 5450" -Verbose

A created ISO can be used for PXE-booting or if you need to emulate a iso as a disk/dvd drive for installation.


It also supports Dell, Lenovo and HP as manufacturers.

🛈 HINT
Because of a Bug/Known issue I´ve split the solution in 3 branches. main has a new switch -DriverInjectionType to control if you want to use the autounattend.xml file with the drivers-folder to apply driver files to the system, or use dism to inject the drivers in the install.wim file. Starting at Windows 11 25H2 it seems to be broken to use a drivers-folder to apply driver files to the system because of a switch in the setup process. So you can use this switch or switch to one of the branches autounattend-driver-injection or dism-driver-injection to use dedicated methods of driver injection.

Parameter defenitions

Check out the following section to learn what the parameters are used for.

.PARAMETER -Windows
    The Major Version of Windows to download. Valid values are 10 or 11.
    The default is 11.

.PARAMETER -Architecture
    The architecture of Windows to download. Valid values are amd64 or arm64.
    The default is x64.

.PARAMETER -Build
    The build number of Windows to download. Valid values are "25H2", "24H2", "23H2" or "22H2".
    The default is the 25H2 build.

.PARAMETER -LanguageCode
    The language code of Windows to download. Valid values for example are en-us, de-de, fr-fr, es-es, it-it.
    The default is en-us.

.PARAMETER -RegionCode
    The regional code of Windows to download. Valid values for example are en-us, de-de, fr-fr, es-es, it-it.
    The default is en-us and will be matched to LanuageCode. if not set.

.PARAMETER -Edition
        The edition of Windows to download. Valid values are "Home", "Pro", "Pro N", "Enterprise", "Enterprise N", "Education", "Education N"
        The default is Pro.

.PARAMETER -UsbDriveLetter
    The drive letter of the USB drive to create the bootable media.
    For example "E:".

.PARAMETER -DriverManufacturer
    The manufacturer of the drivers to download. Valid values are "Dell", "Lenovo", "HP".
    The default is not set.

.PARAMETER -DriverModel
    The model of the drivers to download. This is optional and will be used to filter the drivers from the manufacturer.
    For example (Dell) "Latitude-5440" or (Lenovo) "ThinkPad X390" or (HP) "Z6 G5".

.PARAMETER -DriverInjectionType
    The type of driver injection to use. Valid values are "AUTOUNATTEND" or "DISM".
    The default is AUTOUNATTEND.

.PARAMETER -Verbose
   Enable verbose output.

How it works?

Check out my blog post to learn how this solution works: MCTCLI

🤝 Contributing

Before making your first contribution please see the following guidelines:

  1. Semantic Commit Messages
  2. Git Tutorials

Made with ❤️ by Niklas Rast

About

This repo contains a powershell tool to create a Windows installation media from cli.

Resources

License

Stars

Watchers

Forks

Contributors