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
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
Don't think CMG is supported by the New-CMBootableMedia cmdlet. Try using CreateMedia.exe instead, has more options, and is what the console is using behind the scenes. Documented here: https://learn.microsoft.com/en-us/intune/configmgr/develop/reference/osd/operating-system-deployment-createmedia.exe
I'll add a note in the post. Thanks