Office 365 - Critical Update Deployment Help

Good catch! I forgot about 32-bit Office on 64-bit Windows. Here’s an updated version for anyone that needs it.

Import-Module $env:SyncroModule

# Check if running as System
$sid = ([System.Security.Principal.WindowsIdentity]::GetCurrent()).User.Value
if ($sid -ne "S-1-5-18") {
    Write-Host "This script needs to be run as System."
    Exit 1
}

$c2rPaths =@(
    "$($env:ProgramFiles)\Common Files\Microsoft Shared\ClickToRun\OfficeC2RClient.exe"
    "${env:ProgramFiles(x86)}\Common Files\Microsoft Shared\ClickToRun\OfficeC2RClient.exe"
)

# Check each path to see which is correct
foreach ($c2rPath in $c2rPaths) {
    $pathExists = Test-Path -Path $c2rPath -PathType Leaf
    if ($pathExists) {
        Write-Host "Updating Office using C2R located at '$($c2rPath)'."
       
        try {           
            $result = Start-Process -FilePath $c2rPath -ArgumentList "/update user displaylevel=false forceappshutdown=true" -PassThru -Wait
        } catch {
            Write-Host "An error occurred updating Office."
            Exit 1
        }
        
        if ($result.ExitCode -eq 0) {
            Write-Host "Successfully called the Office C2R updater."
        } else {
            Write-Host "The Office C2R updater was not called successfully. Please investigate."
            Rmm-Alert -Category "Windows | Application Management" -Body "The Office C2R updater was not called successfully. Please investigate."
        }
    }
}
3 Likes