Another critical element to determine to be able to provide support to an end-user is their Office Update Channel as it dictates what updates, build no., are available to them. So this is required to know if their installation is up-to-date, or not.
I came across a webpage that indicated the fact that each Update Channel used a different URL. With this information in hand, I figure we could build a function to cross-reference the PC’s URL against the list to determine the current update channel.
Below is what I came up with.
'---------------------------------------------------------------------------------------
' Procedure : PS_GetOfficeUpdateChannel
' Author : Daniel Pineault, CARDA Consultants Inc.
' Website : http://www.cardaconsultants.com
' Purpose : Determine the Office Update Channel
' Copyright : The following is release as Attribution-ShareAlike 4.0 International
' (CC BY-SA 4.0) - https://creativecommons.org/licenses/by-sa/4.0/
' Req'd Refs: None required
' References:
' https://docs.microsoft.com/en-us/mem/configmgr/sum/deploy-use/manage-office-365-proplus-updates#bkmk_channel
' https://techcommunity.microsoft.com/t5/office-365-blog/how-to-manage-office-365-proplus-channels-for-it-pros/ba-p/795813
' Usage:
' ~~~~~~
' PS_GetOfficeUpdateChannel("")
' Returns -> Current ("Monthly")
'
' Revision History:
' Rev Date(yyyy-mm-dd) Description
' **************************************************************************************
' 1 2021-10-28 Initial Release
'---------------------------------------------------------------------------------------
Public Function PS_GetOfficeUpdateChannel() As String
On Error GoTo Error_Handler
Dim sCmd As String
Dim sOfficeUpdateCDN As String
sCmd = "try{" & vbCrLf & _
"$UpdateCDN = [Microsoft.Win32.RegistryKey]::OpenBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine, [Microsoft.Win32.RegistryView]::Registry64).OpenSubKey('SOFTWARE\Microsoft\Office\ClickToRun\Configuration').GetValue('CDNBaseUrl')" & vbCrLf & _
"}catch{" & vbCrLf & _
"$UpdateCDN = [Microsoft.Win32.RegistryKey]::OpenBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine, [Microsoft.Win32.RegistryView]::Registry32).OpenSubKey('SOFTWARE\Microsoft\Office\ClickToRun\Configuration').GetValue('CDNBaseUrl')" & vbCrLf & _
"}" & vbCrLf & _
"$UpdateCDN = $UpdateCDN -Split '/'|Select -Last 1" & vbCrLf & _
"$UpdateCDN"
sOfficeUpdateCDN = PS_GetOutput(sCmd)
sOfficeUpdateCDN = Replace(sOfficeUpdateCDN, vbNewLine, "") 'Remove extra line feed
Select Case LCase(sOfficeUpdateCDN)
Case LCase("492350f6-3a01-4f97-b9c0-c7c6ddf67d60")
PS_GetOfficeUpdateChannel = "Current Channel"
Case LCase("64256afe-f5d9-4f86-8936-8840a6a4f5be")
PS_GetOfficeUpdateChannel = "Current Channel (Preview)"
Case LCase("7ffbc6bf-bc32-4f92-8982-f9dd17fd3114")
PS_GetOfficeUpdateChannel = "Semi-Annual Enterprise Channel"
Case LCase("b8f9b850-328d-4355-9145-c59439a0c4cf")
PS_GetOfficeUpdateChannel = "Semi-Annual Enterprise Channel (Preview)"
Case LCase("55336b82-a18d-4dd6-b5f6-9e5095c314a6")
PS_GetOfficeUpdateChannel = "Monthly Enterprise"
Case LCase("5440fd1f-7ecb-4221-8110-145efaa6372f")
PS_GetOfficeUpdateChannel = "Beta"
Case LCase("f2e724c1-748f-4b47-8fb8-8e0d210e9208")
PS_GetOfficeUpdateChannel = "LTSC"
Case LCase("2e148de9-61c8-4051-b103-4af54baffbb4")
PS_GetOfficeUpdateChannel = "LTSC Preview"
Case Else
PS_GetOfficeUpdateChannel = "Non CTR version / No Update Channel selected."
End Select
Error_Handler_Exit:
On Error Resume Next
Exit Function
Error_Handler:
MsgBox "The following error has occured" & vbCrLf & vbCrLf & _
"Error Number: " & Err.Number & vbCrLf & _
"Error Source: PS_GetOfficeUpdateChannel" & vbCrLf & _
"Error Description: " & Err.Description & _
Switch(Erl = 0, "", Erl <> 0, vbCrLf & "Line No: " & Erl) _
, vbOKOnly + vbCritical, "An Error has Occured!"
Resume Error_Handler_Exit
End Function
Then, you can use this function by doing something like:
Dim sOfficeUpdateChannel as String
sOfficeUpdateChannel= PS_GetOfficeUpdateChannel
or
MsgBox PS_GetOfficeUpdateChannel, vbInformation or vbOKOnly, "Office Update Channel"
Do note that I have only tested this in a very limited manner, but it did appear to work properly.
When I try compiling this in Access VBA it doesn’t recognise the PS_GetOutput function.
Ah, got it. I just added the code from https://www.devhut.net/vba-run-powershell-command/
Thank you for setting this up, Daniel.