Hi,
The version of Office 365 cannot be retrieved from the WMI class win32_product and it appears OfficeC2RClient.exe calls OfficeClickToRun.exe to update Office 365. If you want to update to a specified version you have to add the "updatetoversion" parameter to OfficeC2RClient. Please check to see if this works for you.
$UpdateEXE ="C:\Program Files\Common Files\microsoft shared\ClickToRun\OfficeC2RClient.exe"
$updatetoversion = "16.0.13127.21348"
$UpdateArguements = "/update user displaylevel=true updatetoversion=$updatetoversion"
$path = "HKLM:\SOFTWARE\Microsoft\Office\ClickToRun\Configuration"
$name = "VersionToReport"
$version = Get-ItemProperty -Path $path | Select-Object -ExpandProperty $name
$ClickToRunSvc = Get-WmiObject win32_service | Where-Object { $_.name -eq 'ClickToRunSvc'}
while($version -ne $updatetoversion){
if($ClickToRunSvc.State -eq 'Stopped'){
Start-Service -Name 'ClickToRunSvc'
Start-Process $UpdateEXE $UpdateArguements -Wait
$ClickToRunSvc = Get-WmiObject win32_service | Where-Object { $_.name -eq 'ClickToRunSvc'}
}
else{
$OfficeClickToRun = Get-Process -Name OfficeClickToRun
if($OfficeClickToRun.count -eq 1){
Start-Process $UpdateEXE $UpdateArguements -Wait
}
else{
Start-Sleep -Seconds 10
}
}
$version = Get-ItemProperty -Path $path | Select-Object -ExpandProperty $name
}
Best Regards,
Ian Xue
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.