Skip to main content

Microsoft 365 - Click-to-Run - Get Details

Summary

This script retrieves the installed Microsoft Click-to-Run Office version on the machine, verifies whether auto-update is enabled, and obtains the update channel.

Sample Run

Sample Run 1
Sample Run 2

Dependencies

Task Creation

Create a new Script Editor style script in the system to implement this task.

Script Editor
Script Editor 2

Name: Microsoft 365 - Click-to-Run - Get Details
Description: This script retrieves the installed Microsoft Click-to-Run Office version on the machine, verifies whether auto-update is enabled, and obtains the update channel.
Category: Application
Category Image

Task

Navigate to the Script Editor section and start by adding a row. You can do this by clicking the Add Row button at the bottom of the script page.
Add Row

A blank function will appear.
Blank Function

Row 1 Function: PowerShell Script

Search and select the PowerShell Script function.
PowerShell Script
PowerShell Script 2

The following function will pop up on the screen:
Function Popup

Paste in the following PowerShell script and leave the Expected time of script execution in seconds to 300 seconds. Click the Save button.

$C2RInfo = Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Office\ClickToRun\Configuration' -ErrorAction SilentlyContinue
if ( $C2RInfo ) {
$version = $C2rInfo.ClientVersionToReport
$autoUpdate = if ($C2RInfo.CDNBaseUrl) {
'1'
} else {
'0'
}
$updateChannel = if ( $C2RInfo.UpdateChannel ) {
switch ( $C2RInfo.UpdateChannel -replace 'http://officecdn.microsoft.com/pr/', '' ) {
'492350f6-3a01-4f97-b9c0-c7c6ddf67d60' {
'Current Channel'
}
'55336b82-a18d-4dd6-b5f6-9e5095c314a6' {
'Monthly Enterprise Channel'
}
'7ffbc6bf-bc32-4f92-8982-f9dd17fd3114' {
'Semi-Annual Enterprise Channel'
}
'b8f9b850-328d-4355-9145-c59439a0c4cf' {
'Semi-Annual Enterprise Channel (Preview)'
}
'64256afe-f5d9-4f86-8936-8840a6a4f5be' {
'Current Channel (Preview)'
}
'5440fd1f-7ecb-4221-8110-145efaa6372f' {
'Beta Channel'
}
'f2e724c1-748f-4b47-8fb8-8e0d210e9208' {
'LTSC Channel (upto Office 2019)'
}
'2e148de9-61c8-4051-b103-4af54baffbb4' {
'LTSC Channel (Preview)'
}
'5030841d-c919-4594-8d2d-84ae4f96e58e' {
'LTSC 2021 Channel (Office 2021+)'
}
default {
'Unknown'
}
}
} else {
'Not Set'
}
$dataCollectionDate = (Get-Date).ToString('yyyy-MM-dd HH:mm:ss')
return "Version=$version|AutoUpdate=$autoUpdate|UpdateChannel=$updateChannel|DataCollectionDate=$dataCollectionDate"
} else {
return 'Office C2R is not installed'
}

Next Row

Row 2 Function: Set User Variable

Add a new row by clicking the Add Row button.
Add Row

Search and select the Set User Variable function.
Set User Variable

The following function will pop up on the screen:
Function Popup

  • Set psout in the Variable Name field.
  • Set %Output% in the Value field.
  • Click the Save button.
    Save Button

Next Step

Row 3 Function: Script Log

Add a new row by clicking the Add Row button.
Add Row

A blank function will appear.
Blank Function

Search and select the Script Log function.
Script Log

The following function will pop up on the screen:
Function Popup

In the script log message, simply type %output% and click the Save button.
Save Log

Row 4 Function: PowerShell Script

Add a new row by clicking the Add Row button.
Add Row

Search and select the PowerShell Script function.
PowerShell Script

The following function will pop up on the screen:
Function Popup

Paste in the following PowerShell script and leave the Expected time of script execution in seconds to 300 seconds. Click the Save button.

$output = '@psout@'
if ( $output -match 'Version=') {
return $($($output -split '\|')[0] -split '=')[1]
} else {
return ''
}

Next Step

Row 5 Function: Set Custom Field

Add a new row by clicking the Add Row button.
Add Row

Search and select the Set Custom Field function.
Set Custom Field

The following function will pop up on the screen:
Function Popup

  • Search and select the Computer-Level Custom Field C2R Office Version from the Custom Field dropdown menu.
  • Set %Output% in the Value field.
  • Click the Save button.
    Save Button

Flag the Continue on Failure field.
Continue on Failure

Row 6 Function: PowerShell Script

Add a new row by clicking the Add Row button.
Add Row

Search and select the PowerShell Script function.
PowerShell Script

The following function will pop up on the screen:
Function Popup

Paste in the following PowerShell script and leave the Expected time of script execution in seconds to 300 seconds. Click the Save button.

$output = '@psout@'
if ( $output -match 'AutoUpdate=') {
if ($($($output -split '\|')[1] -split '=')[1] -eq 1) {
return 'Enabled'
} else {
return 'Disabled'
}
} else {
return ''
}

Next Step

Row 7 Function: Set Custom Field

Add a new row by clicking the Add Row button.
Add Row

Search and select the Set Custom Field function.
Set Custom Field

The following function will pop up on the screen:
Function Popup

  • Search and select the Computer-Level Custom Field C2R Auto Update from the Custom Field dropdown menu.
  • Set %Output% in the Value field.
  • Click the Save button.
    Save Button

Flag the Continue on Failure field.
Continue on Failure

Row 8 Function: PowerShell Script

Add a new row by clicking the Add Row button.
Add Row

Search and select the PowerShell Script function.
PowerShell Script

The following function will pop up on the screen:
Function Popup

Paste in the following PowerShell script and leave the Expected time of script execution in seconds to 300 seconds. Click the Save button.

$output = '@psout@'
if ( $output -match 'UpdateChannel=') {
return $($($output -split '\|')[2] -split '=')[1]
} else {
return ''
}

Next Step

Row 9 Function: Set Custom Field

Add a new row by clicking the Add Row button.
Add Row

Search and select the Set Custom Field function.
Set Custom Field

The following function will pop up on the screen:
Function Popup

  • Search and select the Computer-Level Custom Field C2R Update Channel from the Custom Field dropdown menu.
  • Set %Output% in the Value field.
  • Click the Save button.
    Save Button

Flag the Continue on Failure field.
Continue on Failure

Row 10 Function: PowerShell Script

Add a new row by clicking the Add Row button.
Add Row

Search and select the PowerShell Script function.
PowerShell Script

The following function will pop up on the screen:
Function Popup

Paste in the following PowerShell script and leave the Expected time of script execution in seconds to 300 seconds. Click the Save button.

$output = '@psout@'
if ( $output -match 'DataCollectionDate=') {
return $($($output -split '\|')[3] -split '=')[1]
} else {
return "$((Get-Date).ToString('yyyy-MM-dd HH:mm:ss'))"
}

Next Step

Row 11 Function: Set Custom Field

Add a new row by clicking the Add Row button.
Add Row

Search and select the Set Custom Field function.
Set Custom Field

The following function will pop up on the screen:
Function Popup

  • Search and select the Computer-Level Custom Field C2R Data Collection Time from the Custom Field dropdown menu.
  • Set %Output% in the Value field.
  • Click the Save button.
    Save Button

Flag the Continue on Failure field.
Continue on Failure

Click the Save button at the top-right corner of the screen to save the script.
Final Save

Completed Task

Completed Task 1
Completed Task 2

Implementation

It is suggested to run the task once per month against computers with the Microsoft 365 Apps installed.

This screen will appear.
Schedule Screen

Select the Schedule button and click the calendar-looking button present in front of the Recurrence option.
Recurrence Option

Select the Days(s) for the Repeat, 14, and click the OK button to save the schedule.
Save Schedule

Click the Select Targets button to select the concerned target.
Select Targets

Search and select the Office C2R Auditing Device Group for the target.
Device Group

Click the Run button to initiate the schedule.
Run Button

Output

  • Script log
    Script Log

  • Custom Fields
    Custom Fields