Featured image of post Automating with PowerShell: Monitoring Office Releases

Automating with PowerShell: Monitoring Office Releases

New Website and upcoming blogs

So I haven’t blogged for the last month, and I’m not gonna tell you that was because I was moving my website to Azure Static Web Apps, because it was not. I just couldn’t find the time or inspiration to write anything down that would be useful to anyone. It happens sometimes and a bit of writers(or bloggers, or PowerShellers) block happens to anyone. Blogging and sharing knowledge is one of the most satisfying things I do so naturally I got a little bit annoyed at myself.

To get back in the game, I’ve decided to move the CyberDrain.com website from my old web host to Azure Static Web Apps. In a “practice what you preach” type of thing I figured that this move makes most sense for me; it gives me a CDN, the capability to stick an API behind some of my stuff, and allow me to edit pages in markdown and not that annoying Wordpress editor that always got me down. ;)

I’ve also decided to start a new blogging series next to my PowerShell blogs, I want to write down some more of my experiences instead of just dropping technical bombs all the time. I’ve often had people tweet or talk about my CTF story times I’ve encountered challenging issues in my business and I believe I have enough fun stories to keep everyone entertained with those as well.

To get started with blogging again I’ve decided to release 3 new blogs in the coming days, of which this is the first. I hope you’ll all enjoy them, and the new platform too.

Automating with PowerShell: Monitoring Office releases

I’ve blogged about monitoring updates for office before but that is a pretty static approach to things; you have to enter the latest version of Office yourself and with the now bi-weekly updates in the preview channel that could get annoying, especially if you want to keep your minimum version the same as the latest released version.

And that’s where this blog enters; Microsoft has a nice API available that tells us exactly which latest version is available for Office, it also tells us exactly which versions are no longer supported and really require an update. This monitoring script tells you which version is currently installed, if it is the latest version, and if not, if the version you are running is still in support by Microsoft.

$ReportedVersion = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Office\ClickToRun\Configuration" -Name "VersionToReport"
$Channel = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Office\ClickToRun\Configuration" -Name "CDNBaseUrl" | Select-Object -Last 1
$CloudVersionInfo = Invoke-RestMethod 'https://clients.config.office.net/releases/v1.0/OfficeReleases'
$UsedChannel = $cloudVersioninfo | Where-Object { $_.OfficeVersions.cdnBaseURL -eq $channel }

if ($UsedChannel.latestversion -eq $ReportedVersion) {
    Write-Host "Currently using the latest version of Office in the $($UsedChannel.Channel) Channel: $($ReportedVersion)"
    exit 0
else {
    Write-Host "Not using the latest version in the $($UsedChannel.Channel) Channel. Check if version is still supported"
    $OurVersion = $CloudVersionInfo.OfficeVersions | Where-Object -Property legacyVersion -EQ $ReportedVersion
    if ($OurVersion.endOfSupportDate -eq "0001-01-01T00:00:00Z") {
        Write-Host "This version does not yet have an end-of-support date. You are running a current version, but not the latest. Your version is $($ReportedVersion) and the latest version is $($UsedChannel.latestVersion)"
        exit 0
    if ($OurVersion.endOfSupportDate) {
        Write-Host "this version will not be supported at $($OurVersion.endOfSupportDate). Your version is $($ReportedVersion) and the latest version is $($UsedChannel.latestVersion)"
        exit 1
    else {
        Write-Host "Could not find version in the supported versions list. This version is most likely no longer support. Your version is $($ReportedVersion) and the latest version is $($UsedChannel.latestVersion). For all supported versions, see below"
        exit 1

As always, Happy PowerShelling

All blogs are posted under AGPL3.0 unless stated otherwise
comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy