Oct 9, 2017

ConfigMgr Techical Preview automated upgrade

Hi all ConfigMgr enthusiasts!

As ConfigMgr new TP rolls out monthly you may want to automate this upgrade process. As always, PowerShell is your firend. With TP1709 I wrote a small script that you can use to semi-automate your upgrade process. With a bit of further developement you can turn this script to update function and schedule it - voilĂ  a fully automated TP upgrade process!

Currently the script checks for new TP update, initiates download, runs prerequisite checks and installs the update. You will have to run this script line-by-line and check for the results before continuing.

Script also grabs some PowerShell cmdlet info from currenty installed version and saves it to a JSON file. After upgrade you can run the info gathering part again and compare JSON files to see what has changed between TP's.

As always, please send comment through Twitter @arisaastamoinen

Cheers,

Ari








# First, lets check for updates
set-location 'LAB:\'

Invoke-CMSiteUpdateCheck -Verbose




# inspect log
get-content 'C:\Program Files\Microsoft Configuration Manager\Logs\dmpdownloader.log' -Tail 10




# Currently installed TP
$CurrentTP = Get-ItemProperty HKLM:\SOFTWARE\Microsoft\SMS\Setup -Name 'Full Version' | select 'Full Version'




# New version
$NewTP = Get-CMSiteUpdate -fast | where {$_.FullVersion -gt $CurrentTP.'Full Version'}




# Do we have something?
$NewTP | select Name,Description,FullVersion




# save some PowerShell cmdlets info from current version

# just the heck of it, lets save to json file
$CurrentTPName = $(Get-CMSiteUpdate -fast | where {$_.FullVersion -eq $CurrentTP.'Full Version'}).Name

$file = "C:\Data\$CurrentTPName.json"

get-command -Module ConfigurationManager | ConvertTo-Json | out-file $file




# check that you got something
Get-Content $file -Tail 100

$NewTP.State




# State was 262146 = Ready To Install, if not then must download it first
Invoke-CMSiteUpdateDownload -InputObject $NewTP -Verbose -Force




# after downloading run prereq checks
Invoke-CMSiteUpdatePrerequisiteCheck -InputObject $NewTP -Verbose




# get state
$NewTP = Get-CMSiteUpdate -fast | where {$_.FullVersion -gt $CurrentTP.'Full Version'}

$NewTP.State




# Changed to 2 "Checking Prerequisities"

# wait and check again...




# Changed to 65537 "Checking Prerequisities"

# wait and check again...




# State changed to 131074 "Prerequiste check succeeded"

# Lets install !
Install-CMSiteUpdate -InputObject $NewTP -SkipPrerequisiteCheck -Force -Verbose







# after update is done, you will have to run the script from the very top until to the JSON part

# then do comparision with json files & powershell cmdlets as you like
 
 
if ($(Get-ItemProperty HKLM:\SOFTWARE\Microsoft\SMS\Setup -Name 'Full Version' | select 'Full Version').'Full Version' -gt $CurrentTP ) {

# New installed TP

$CurrentTP = Get-ItemProperty HKLM:\SOFTWARE\Microsoft\SMS\Setup -Name 'Full Version' | select 'Full Version'

$CurrentTPName = $(Get-CMSiteUpdate -fast | where {$_.FullVersion -eq $CurrentTP.'Full Version'}).Name

$file = "C:\Data\$CurrentTPName.json"

get-command -Module ConfigurationManager | ConvertTo-Json | out-file $file

Get-Content $file -Tail 100



}