question

RickSomeone-1151 avatar image
0 Votes"
RickSomeone-1151 asked AlexZhu-MSFT commented

PowerShell and Office upgrade.

I asked this in the PowerShell group and got lots of helpful suggestions and scripts to test, but none of them actually worked properly. I just need PS to check the version of winword and compare it to the latest version we are using and upgrade it if needed, then end.

What I started with was:

$UpdateEXE ="C:\Program Files\Common Files\microsoft shared\ClickToRun\OfficeC2RClient.exe"
2. $UpdateArguements = "/update user displaylevel=true"
3. $updatetoversion="16.0.etc"
4. $version = Get-WmiObject win32_product | where{$_.Name -like "Microsoft Office Professional Plus*"} | Select-Object -ExpandProperty Version
5. while($version -ne $updatetoversion){
6. Start-Process $UpdateEXE $UpdateArguements -Wait
7. }

This checks the version, runs an update, but then stops with a popup:
Your Office has been upgraded, so I have to click OK for the next version check and upgrade to take off.
Some of our pc's are at version 1705, some at 2002....we need 2008.
**So after clicking OK at the popup window, the 2nd upgrade runs, gets me to where I need to be, but then is stuck in a loop of "Checking for Updates" endlessly.
Any idea why this would be?
I know I have a 'while' but I have no condition telling it what to do once the version matches. That part I don't have.

mem-cm-updates
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@RickSomeone-1151
As this case involves PowerShell commands, but tag "office-itpro" focus more on general issues of Office clients, I will verify whether there is the right team to help you.

0 Votes 0 ·

Hi,

Firstly, mem-cm stands for Microsoft Endpoint Manager - Configuration Manager (short for MCEM). It seems this problem is not MECM related. I'm not familar with Office and I'd like to share my idea and hope it helps.

1, the pop-up windows is from OfficeC2RClient.exe /update user displaylevel=true, which seems no way to control it via Start-Process cmdlet. Is there any other parameter to control the pop-up windows of OfficeC2RClient.exe, for example, /siliently, /no-interactive, etc.?
2, the loop is the expected behavior, since there is no version is equal to "16.0.etc" exactly, the "OfficeC2RClient.exe /update user displaylevel=true" command will run endlessly.

79528-scom-powershell-04.png

Regards,

Alex
If the response is helpful, please click "Accept Answer" and upvote it.


0 Votes 0 ·

1 Answer

wahaha010 avatar image
0 Votes"
wahaha010 answered

while($version -ne $updatetoversion){Start-Process $UpdateEXE $UpdateArguements -Wait}

this code has no "break" word.

likie this:

while(true){}

always do the same thing. Read some docs about "while".


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.