Streamlining Office Updates via Intune: Accelerating Your Workflow

In the fast-paced world of software, staying up-to-date is non-negotiable. But what about those times when you’re left without a seamless solution to expedite Office updates, much like the way Windows Update for Business handles zero-day updates? If you’ve been seeking a remedy for this situation, your search might just end here.

Introducing a Potential Solution

The answer lies in two ingenious scripts that can transform how you manage Office installations configured with ClickToRun. By bridging the gap between the lack of expedited Office updates and the need for swift action, these scripts empower you to take control of the update process.

Script #1: Identifying the Update Lag Begin by crafting a script – let’s call it “DetectCurrentOffice.ps1”. This script zeroes in on the OfficeC2RClient.exe and assesses its version against a defined benchmark, $notUpdatedVersion. If the current version falls short of this benchmark, the script will gracefully exit with a return value of “1”. This particular value serves as the trigger for the remediation script, indicating that it’s time to intervene and initiate the update process. Remember, you can adjust the benchmark version to cater to your specific update goals, ensuring your Office software is consistently up-to-date.

#Detection Script Start
$Logfile = "C:\ProgramData\Microsoft\IntuneManagementExtension\Logs\OfficeVersionCheck.log"
function WriteLog
{
Param ([string]$LogString)
$Stamp = (Get-Date).toString("yyyy/MM/dd HH:mm:ss")
$LogMessage = "$Stamp $LogString"
Add-content $LogFile -value $LogMessage
}

$notUpdatedversion= "16.0.16529.20226"


try {
    #$c2r=get-item "$($Env:ProgramFiles)\Common Files\microsoft shared\ClickToRun\OfficeC2RClient.exe"

    $c2r=get-item "$($Env:ProgramFiles)\Microsoft Office\root\Office16\winword.exe"
    

    if([version]$c2r.versioninfo.FileVersion -lt [Version]$notUpdatedVersion) {
        WriteLog "Detected: OUT DATED VERSION Installed: OfficeC2RClient ($($c2r.versioninfo.FileVersion)) is old with a version of $($notUpdatedversion)"
        exit 1
    }
    else {
        WriteLog "Detected: Your Version upto date all Good: OfficeC2RClient ($($c2r.versioninfo.FileVersion)) has a date of $($notUpdatedversion)"
        exit 0
         

    }
}
catch {
    WriteLog  "Detected: Office Click2Run not found!"
    exit 0
}


Script #2: Orchestrating the Update The second script – “RemediationScript.ps1” – comes into play as the designated facilitator of the update process. This script takes charge by invoking the OfficeC2RClient, which in turn will initiate the update of your Office installation. Delve deeper into the script, and you’ll find the version parameter meticulously set to 16.0.16529.20226. But that’s not all – the script also offers control over the update process itself. With forceappshutdown set to false, your users won’t experience abrupt interruptions, allowing them to wrap up their work smoothly. Furthermore, the displaylevel parameter set to true ensures that your end users are informed about the update progress, allowing them to safeguard their work before the updates finalize.

#Remediation Script Start
$Logfile = "C:\ProgramData\Microsoft\IntuneManagementExtension\Logs\OfficeVersionCheck.log"
function WriteLog
{
Param ([string]$LogString)
$Stamp = (Get-Date).toString("yyyy/MM/dd HH:mm:ss")
$LogMessage = "$Stamp $LogString"
Add-content $LogFile -value $LogMessage
}

$notUpdatedAfter= "16.0.16529.20226"

try {
   
        $c2r=get-item "$($Env:ProgramFiles)\Microsoft Office\root\Office16\winword.exe"
        if([version]$c2r.versioninfo.FileVersion -lt [version]$notUpdatedAfter) {
        # OK, so we need to get the current click2run process so we do not confuse the launched one with the preexisting one
        $initialProcesses=get-process -name "OfficeClickToRun"
        WriteLog "Remediating: Spawning update as OfficeC2RClient ($($c2r.versioninfo.FileVersion)) is old with a new $($notUpdatedAfter)"
        $newProcess=start-process -FilePath "$($env:ProgramFiles)\Common Files\microsoft shared\ClickToRun\OfficeC2RClient.exe" -argumentlist "/update user forceappshutdown=false displaylevel=true updatetoversion=16.0.16529.20226" -passthru -wait
        # sleep a little to allow it to start
        start-sleep -seconds 60
        # Get the new process (if it exists)
        $spawnedProcess=(get-process -name "OfficeClickToRun"|where {-not($_.id -in $initialProcesses.id)})
        if ($spawnedProcess) {
            wait-process $spawnedProcess.id
        }
        # Keeps being reported as recurring in proactive remediations - maybe we're exiting too fast?
        start-sleep -seconds 60 
        $c2r=get-item "$($Env:ProgramFiles)\Microsoft Office\root\Office16\winword.exe"
        WriteLog "Remediated: Post Update: OfficeC2RClient has version of ($($c2rafter.versioninfo.FileVersion)) with a version of $($notUpdatedAfter)"


        exit 0
    }
    else {
        WriteLog "Remediated: OfficeC2RClient ($($c2r.versioninfo.FileVersion)) has updated to $($notUpdatedAfter)"
        exit 0
    }
}
catch {
    WriteLog "Detected: Office Click2Run not found!"
    exit 0
}
       

Incorporating these scripts into your workflow can revolutionize how you handle Office updates via Intune. With a precise approach to identifying lagging versions and a strategic method for orchestrating the update process, you’ll no longer be at the mercy of delays or inconsistencies in your Office software updates. Instead, you’ll be driving efficiency and ensuring that your software environment remains up-to-date, secure, and in sync with your operational needs