OSDCloud – ConfigMgr Integrated – Win11 OSD

So, for a lab where you want to get up and running with OSD as soon as possible, this is a great trick. You can have an OSD Task Sequence, using OSD Cloud, so all of the content is hosted in the cloud thanks to Microsoft and hardware vendors, and your scripts integrated into the Task Sequence or hosted on GitHub.

TLDR: Download the Task Sequence Export: OSDCloud Task Sequence (2561 downloads )

Bunny Trail – Hosting your Task Sequence PowerShell in GitHub

Quick Note, you can host any of your PowerShell Scripts you want to run in a TS on GitHub, then call them using a simple command: (just replace the URL with the RAW location of where your script is on GitHub)

powershell.exe -executionpolicy bypass -command "Invoke-Expression (Invoke-RestMethod 'https://raw.githubusercontent.com/gwblok/garytown/master/OSD/CloudOSD/Set-ThisPC.ps1')"

This has several advantages in a lab

  • Your content is managed in GitHub with all of the features that brings.
  • Your TS is smaller then having embedded scripts which can cause issues
  • You don’t need to update a package, if you keep the scripts in packages
  • Makes it easy for you to have several labs all sharing the same Task Sequence scripts, so you can update one script in github, and all of your labs will be updated.

Many of the steps in the task sequence I’m providing point to my personal GitHub, and I recommend that you make copies of those scripts and place in your own GitHub.

Overview of TS

OSD Cloud Steps

Prepping WinPE for OSDCloud

cmd.exe /c start /wait powershell.exe -executionpolicy bypass -command "Invoke-Expression (Invoke-RestMethod 'sandbox.osdcloud.com')"

If you want to know exactly what is going on, just head over to sandbox.osdcloud.com and look at the script for yourself, but to summarize, it’s prepping WinPE to enable the PowerShell Gallery and adding the requirements for that, then adds CURL.exe, which is the main download utility that OSDCloud uses, and adds a few modules.

OSD Cloud Apply OS

cmtrace x:\windows\temp\smstslog\smsts.log
Write-Output "--------------------------------------"
Write-Output ""
Write-Output "OSDCloud Apply OS Step"
Write-Output ""
#Set OSDCloud Params
$OSName = "Windows 11 22H2 x64"
Write-Output "OSName: $OSName"
$OSEdition = "Enterprise"
Write-Output "OSEdition: $OSEdition"
$OSActivation = "Volume"
Write-Output "OSActivation: $OSActivation"
$OSLanguage = "en-us"
Write-Output "OSLanguage: $OSLanguage"

$Global:MyOSDCloud = [ordered]@{
        Restart = [bool]$False
        RecoveryPartition = [bool]$True
        SkipAllDiskSteps = [bool]$True
        #DriverPackName = "None"
    }

Write-Output "Global:MyOSDCloud"
$Global:MyOSDCloud

#Update Files in Module that have been updated since last PowerShell Gallery Build (Testing Only)
$ModulePath = (Get-ChildItem -Path "$($Env:ProgramFiles)\WindowsPowerShell\Modules\osd" | Where-Object {$_.Attributes -match "Directory"} | select -Last 1).fullname
import-module "$ModulePath/OSD.psd1" -Force

#Launch OSDCloud
Write-Output "Launching OSDCloud"
Write-Output ""
Write-Output "Start-OSDCloud -OSName $OSName -OSEdition $OSEdition -OSActivation $OSActivation -OSLanguage $OSLanguage"
Write-Output ""
Start-OSDCloud -OSName $OSName -OSEdition $OSEdition -OSActivation $OSActivation -OSLanguage $OSLanguage
Write-Output ""
Write-Output "--------------------------------------"
get-process -name cmtrace | stop-process

So that step calls OSDCloud with specific parameters, and sets up Windows!

Update Offline OS

First we’re going to learn about the OS that is installed Offline and write that information into TS Variables.

Get Offline UBR

$Info = DISM.exe /image:c:\ /Get-CurrentEdition
$OfflineUBR = ($Info | Where-Object {$_ -match "Image Version"}).replace("Image Version: ","")
$OfflineUBR

Get Offline Build

$Info = DISM.exe /image:c:\ /Get-CurrentEdition
$OfflineUBR = ($Info | Where-Object {$_ -match "Image Version"}).replace("Image Version: ","")
$OfflineBuild = $OfflineUBR.Split(".")[2]
$OfflineBuild

Now we’re going to MANUALLY keep updated the CUs for the OS types we plan to deploy and keep them in TS Variables. This was done by going to the Microsoft Catalog and finding the URLs to the correct KBs.

Then we have the TS pick which update we should use based on the Offline UBR

Now we just create some extra information to assist with logging and troubleshooting.

Get MSU

param (
    [string]$URL
)
$CUMSU = $URL.Split("/") | Select-Object -Last 1
$CUMSU

Get KB

param (
    [string]$URL
)
$CUMSU = $URL.Split("/") | Select-Object -Last 1
$KB = ($CUMSU.Split("-")[1]).ToUpper()
$KB

Recording KB info into SMSTS Log

This step leverages the “OSD” powershell module (OSDCloud), which has a function to look up KB information directly from MS Catalog. (Get-MsUpCat), it then writes it out to the SMSTS.log, as well as capturing info into TS Vars.

OS Customizations

Once the OS has been applied and updated, then I start to add some customizations offline, after that, I get it to install the CM Agent, import the Domain Certificate, and then some additional online customizations. I’m only going to cover a few more things, rest of it you can just dig through, take what you want, ask questions if you have any…

Setup Branch Cache – 2Pint

This step calls the 2Pint script from their github to do the initial configuration of BC on the device. 2Pint are the experts in this space, so I just let them do it for me by pointing at their scripts.

Sysinternals & WMIExplorer

These two Steps both grab the installers directly from the vendors or GitHub and install on your system, along with creating shortcuts. The Scripts are maintained in my personal github.

Install Updates

This step is a modified version of something I posted perviously to GitHub: WindowsUpdateFunctions.ps1 at master · gwblok/garytown (github.com)

GARYTOWN.COM

2 thoughts on “OSDCloud – ConfigMgr Integrated – Win11 OSD”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.