PowerShell and Office upgrade.

Rick Someone 411 Reputation points
2021-03-17T14:21:56.857+00:00

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.

Microsoft Configuration Manager Updates
Microsoft Configuration Manager Updates
Microsoft Configuration Manager: An integrated solution for for managing large groups of personal computers and servers.Updates: Broadly released fixes addressing specific issue(s) or related bug(s). Updates may also include new or modified features (i.e. changing default behavior).
969 questions
{count} votes

1 answer

Sort by: Most helpful
  1. wahaha 41 Reputation points
    2021-03-19T09:39:56.41+00:00

    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".

    0 comments No comments