Creating a ConfigMgr (SCCM) Bootable Media – PowerShell Style

Here is a PowerShell script that will create Bootable Media for ConfigMgr. In this example, I generate an ISO file and add a prestart command / package (to launch the TSBackground solution from Johan Schrewelius).

Note: If you are running into limitations with the New-CMBootableMedia cmdlet, like specifying a CMG MP, you can also use the createmedia.exe tool that comes with ConfigMgr, and that the console is using behind the scenes. It has many more options, and is documented here: https://learn.microsoft.com/en-us/intune/configmgr/develop/reference/osd/operating-system-deployment-createmedia.exe

# Requires the script to be run under an administrative account context.
#Requires -RunAsAdministrator

# Set variables
$SiteCode = "PS1"
$DPName = "dp01.corp.viamonstra.com"
$MPName = "cm01.corp.viamonstra.com"
$ISOFile = "E:\Setup\Bootimage_TSB.iso"
$BootImageName = "WinPE 11 22H2 X64 - TSB"
$PrestartPackageName = "TSBackground"

# Import ConfigMgr Module
Import-Module (Join-Path $(Split-Path $env:SMS_ADMIN_UI_PATH) ConfigurationManager.psd1)
Set-Location "$SiteCode`:"

# Get objects for bootable media
$BootImage = Get-CMBootImage -Name $BootImageName
$DP = Get-CMDistributionPoint -SiteSystemServerName $DPName
$MP = Get-CMManagementPoint -SiteSystemServerName $MPName
$PrestartPackage = Get-CMPackage -Name $PrestartPackageName -Fast

# Configure settings for Bootable media
$BootableMedia_Params = @{
    MediaMode             = "SiteBased"
    MediaType             = "CdDvd"
    Path                  = $ISOFile
    AllowUnknownMachine   = $true
    BootImage             = $BootImage
    DistributionPoint     = $DP
    ManagementPoint       = $MP
    AllowUnattended       = $false
    Force                 = $true
    PrestartCommand       = "WSCript.Quit(0)"
    PrestartPackage       = $PrestartPackage
    
}

# Create bootable media
New-CMBootableMedia @BootableMedia_Params
About the author

Johan Arwidmark

4 1 vote
Article Rating
Subscribe
Notify of
guest
2 Comments
Newest
Oldest Most Voted
zay
zay
2 months ago

I know this is an old thread, but have a question. Is there a way to use the script for creating boot media for use in autpilot that utilizes the CMG? I can select the cmg when using the mecm boot media creation wizard, but it does not accept the url for the MP/CMG in the script. My CMG MP is for example https://MYUSCMG.EOSTUS.CLOUDAPP.AZURE.COM. Any thoughts on that

Last edited 2 months ago by zay

>