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



}

 
 
 
 

Sep 6, 2017

DFSR Replication Schedules with PowerShell

The other day one I had to tune DFS replication schedules. No big problem but too much clicking if you have tens or maybe hundreds of replication groups. How to make sure each replication group has correct schedule? With PowerShell, of cource.

Bandwith details in the GUI might look like this

Schedule gone baad

 Each block in the GUI is one hour. Block coloring has three variants in which partially colored means Bandwith usage is "something else than No Replication or Full", somewhere between 16Kbps and 256Mbps.

So it was time to do some PowerShell and fix these replication schedules without pain.





PowerShell has a module DFSR with 45 different cmdlets, the two we're now interested in are Get-DfsrGroupSchedule and Set-DfsrGroupSchedule.

As bandwith is limited and I had 20+ replication groups doing their stuff, things started to slow down as DFSR saturated the WAN connection. I decided to go the easy way here so I set the same schedule for all of my replication groups, after the initial replication has finished I'll tune these schedules up to higher values but now 256Kbps is enough, this will use approx 5Mbps of my 10Mbps.

Below is the script that I ran. Things started to flow smoothly when the receiving DFS service picked up new shedule, you can speed up this by replicating AD connecitons and running gpupdate (/force).

Cheers,

Ari


# Each slot is 15min, four slots in one hour, from 00:00 - 24:00, total of 96 slots
# Bandwith: F = Full, 4 = 256Kbps
# https://technet.microsoft.com/fi-fi/itpro/powershell/windows/dfsr/set-dfsrgroupschedule
$fullSched = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
$slowSched = "FFFFFFFFFFFFFFFFFFFFFFFF4444444444444444444444444444444444444444444444444444444444444444FFFFFFFF"

# "FFFFFFFFFFFFFFFFFFFFFFFF".length/4 = 6 hours, from midnight to 6am
# "FFFFFFFFFFFFFFFFFFFFFFFF4444444444444444444444444444444444444444444444444444444444444444".length/4 = 22, until 10pm
 
 

# save old schedule
 
 
Get-DfsrGroupSchedule | select GroupName,BandwidthDetail | fl | Out-File -FilePath C:\temp\rgscheds-2017-09-06.txt

# get all schedules and modify
$groupSched = Get-DfsrGroupSchedule | select GroupName
foreach ($g in $groupSched) {
Set-DfsrGroupSchedule -GroupName $g.GroupName -Day Monday,Tuesday,Wednesday,Thursday,Friday -BandwidthDetail $slowSched
Set-DfsrGroupSchedule -GroupName $g.GroupName -Day Saturday,Sunday -BandwidthDetail $fullSched
}