Since Service Pack 1 was released to SCCM 2012 R2 I have been upgraded several environments. A couple of customers wanted me to create a PowerShell script to uninstall existing ConfigMgr Console and install the new updated version with the latest cumulative updates and hotfixes.

If you create a package to distribute it with SCCM make sure you point the Data source to the location of the Client installations files, Script, KB3084586-msp and kb3074857-msp.

Installation command for the program will then be: PowerShell.exe -file “script.ps1”.

Remember to set PowerShell execution policy to “Bypass” under Client Settings. This will not affect policy’s on the Windows environments, only scripts run from ConfigMgr will work).



If you have any questions, please live a comment below!

Script:

<# 
    .NOTES 
    ===========================================================================     
    Created on:   28.08.201509.31     
    Created by:   Marius A. Skovli      
    Organization: Coretech      
    Filename:Upgrade System Center Configuration Manager Console    
    =========================================================================== 
    .DESCRIPTION   

    A description of the file. 
#> 

$SiteServer = SERVER NETBIOS

# Get script folder 
function Get-ScriptDirectory { 
$Invocation = (Get-Variable MyInvocation -Scope 1).Value 
Split-Path $Invocation.MyCommand.Path 
} 
$ScriptFolder = Get-ScriptDirectory 

# Uninstall old System Center Configuration Manager Console version 
Get-WmiObject -Class Win32_Product | Where-Object {$_.Name -like "System Center 2012 * Configuration Manager Console"} | ForEach-Object -Process {$_.Uninstall()} 

# Install System Center Configuration Manager Console
$ConsoleInstallArguments = {TargetDir="C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole" DEFAULTSITESERVERNAME=$SiteServer ENABLESQM=0/q}
(Start-Process -FilePath $ScriptFolder\ConsoleSetup.exe $ConsoleInstallArguments -Wait -Passthru).ExitCode

# Install System Center R2 SP1 Configuration Manager CU1
$CU1InstallArguments ="/p $ScriptFolder\configmgr2012adminui-sp2r2sp1-kb3074857-i386.msp /q REBOOT=ReallySuppress REINSTALL=ALL REINSTALLMODE=mous"
(Start-Process -FilePath "msiexec.exe" $CU1InstallArguments -Wait -Passthru).ExitCode

# Install System Center R2 SP1 Configuration Manager CU1 KB3084586
$KB3084586InstallArguments ="/p $ScriptFolder\configmgr2012adminui-sp2r2sp1-kb3084586-i386.msp /q REBOOT=ReallySuppress REINSTALL=ALL REINSTALLMODE=mous"
(Start-Process -FilePath "msiexec.exe" $KB3084586InstallArguments -Wait -Passthru).ExitCode

IF ($LastExitCode -ne 0){
Write-Host Cool!
}