Menu
CCMEXEC.COM – Enterprise Mobility
  • Home
  • General
  • Configuration Manager
  • Windows 10
  • Windows 11
  • Intune
  • GitHub
  • About
CCMEXEC.COM – Enterprise Mobility

Installing updates during OSD using PSWindowsUpdate

Posted on September 9, 2022September 9, 2022 by Jörgen Nilsson

When we move workloads to Intune in our Co-Management scenarios we lose some features we have been using and need to go back to basic. In this short post we will install updates during OSD using the PSWindowsUpdate module which is great. When we moved the Windows Update workload and uninstalled WSUS we need another way of installing updates. I did a lot of testing and excluding drivers and all updates with “preview” in the title works really well.

Start by saving the PSWindowsUpdate module to a temp directory on a computer, we download it so we can add it to our CM Package we us to install updates.

Save-module PsWindowsUpdate -Path C:\Module

That will create the following folder with the module inside

Then we save the script below in the same folder. The script will do the following:

  • Copy the PSWindowsUpdate module to the local computer
  • Read the TS variable for the location of the SMSTS.log folder
  • Install updates from Windows Update excluding Drivers category and updates with “Preview” in the title.
  • Log the progress to a log file in the CCM\Logs folder
# Script to install updates from Microsoft Update during OSD
# Jorgen@ccmexec.com

# Copy PSWindowsUpdate module
$TargetPath = Join-Path -Path $env:ProgramFiles -ChildPath "WindowsPowerShell\Modules"
mkdir $TargetPath -Force -ErrorAction Stop | Out-Null
Copy-item -path $PSScriptRoot'\PSWindowsUpdate' -Destination $TargetPath -Recurse
  
# Get SMSTSLog folder
$tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment
$SMSTSLogfile = $tsenv.Value("_SMSTSLogPath")
$SMSTSLogfilepath = $SMSTSLogfile.Replace("\SMSTS.log", "")

# Install updates from Microsoft Update
Import-Module PSWindowsUpdate
Get-WindowsUpdate -AcceptAll -Install -NotCategory "Drivers" -NotTitle Preview -WindowsUpdate -IgnoreReboot | Out-File "$SMSTSLogfilepath\WindowsUpdate-$(get-date -f yyyy-MM-dd).log" -force

Our source folder now looks something like this and can be copied to our MEMCM Source folder share.

In Configuration Manager we create a Package with source files and distribute them to the relevant DP’s.

In our Task Sequence we add the following steps, note the Restart Computer steps, I had to add two restart computer steps to get all of my physical test machines to not break the task sequence engine with an unexpected reboot. Be sure to test that out!

A tip if you are piloting moving Windows Update for business, add a variable to the Co-Management Pilot collection. Then we can use that as a condition to run updates using this script or using Configuration Manager depending on the variable.
I will post more on Co-Management and prestaging a Co-Managed computer soon

9 thoughts on “Installing updates during OSD using PSWindowsUpdate”

  1. Pingback: Installing updates during OSD using PSWindowsUpdate - CCMEXEC.COM - News
  2. Andy says:
    January 13, 2023 at 11:00 pm

    Could you explain what the “TSBStatus04” step is?

    Reply
    1. admin says:
      January 17, 2023 at 9:15 pm

      That is a step to change the Background status displayed by TSBackground during OSD.
      https://ccmexec.com/2019/06/tsbackground-for-configmgr/
      Regards,
      Jörgen

      Reply
  3. Anthony says:
    February 8, 2023 at 1:53 am

    Does this solution also apply Feature Updates to Win10/Win11? I would want to suppress that if possible

    Reply
  4. Morten WIingreen says:
    October 6, 2023 at 10:05 am

    Hi Jörgen,
    I am trying to get your scritp to run during a very simple TS installing Windows 11.
    DO you know of any problems with windows 11 and PSWindowsUpdate or the way teh scripts functions.

    Reply
  5. John says:
    October 12, 2023 at 3:46 pm

    Anthony’s question is pertinent 😉

    The reason I’m looking at this solution is that we currently deploy language packs during task sequence, using variables. We have around 20 languages in our environment so putting them in the image is a bit ridiculous.

    The problem is that when you install a language pack, you must install a CU after it, or stuff breaks. Since we moved workload to WUFB/Intune, the Install Updates step broke.

    Installing the cab file of the CU as a package also doens’t seem to work now (at least not with W11 22H2 from my testing).

    So your solution looks like a life saver, many thanks. I will test and report back ;).

    Reply
  6. John says:
    October 13, 2023 at 12:05 pm

    So have now tested this using W11 22H2 and W1021H2

    I tried offline media and PXE

    Everything worked very nicely, and now feature update was applied to the W10 21H2 device despite one being available.

    Fixed my issues with installation of lang packs in TS for both W11 and W10.

    Full marks 😉

    Reply
    1. John says:
      October 17, 2023 at 2:46 pm

      “Everything worked very nicely, and now feature update was applied to the W10 21H2 device despite one being available.”

      Should have read :

      “Everything worked very nicely, and NO feature update was applied to the W10 21H2 device despite one being available.”

      This is in reply to Anthony’s question above.

      Reply
  7. bart says:
    February 5, 2025 at 12:46 pm

    hello,
    it is working for the normal updates but not for the net framework cumulative updates.
    Is there a special filter needed

    thank you

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

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

My name is Jörgen Nilsson and I work as a Senior Consultant at Onevinn in Malmö, Sweden. This is my blog where I will share tips and stuff for my own and everyone elses use on Enterprise Mobility and Windows related topics.
All code is provided "AS-IS" with no warranties.

Recent Posts

  • New settings in Intune Security Baseline Windows 11 24H2 -2504
  • Managing extensions in Visual Studio Code
  • Reinstall a required Win32app using remediation on demand
  • Administrator protection in Windows 11 – First look
  • Remediation on demand script – ResetWindowsUpdate
©2025 CCMEXEC.COM – Enterprise Mobility | WordPress Theme by Superb Themes
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish.Accept Reject Read More
Privacy & Cookies Policy

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT