Trying to update Office to acertain version

Rick Someone 411 Reputation points
2021-03-02T18:27:39.703+00:00

I'm using PS to generally say, this is my current version. What version do I have, and run the PS to upgrade Office until I get to that current version.

I was using variables

$UpdateToVersion="16.0.13127.xxxx"

$updateEXE="C:\path to OfficeC2Run.exe"

$Update arguments="/update user displaylevel=true"

$version=Get-WmiObject win32_product | where{$_.Name -like "Microsoft Office 365"} | Select-Object -ExpandProperty Version

while($version -lt $UpdateToVersion){

Start-Process $UpdateEXE $UpdateArguments

I've been reading that querying the win32_product is not the proper way to get a version. It completely locks up the pc.

Office Management
Office Management
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Management: The act or process of organizing, handling, directing or controlling something.
2,040 questions
Not Monitored
Not Monitored
Tag not monitored by Microsoft.
36,994 questions
{count} votes

6 answers

Sort by: Most helpful
  1. Garth 5,801 Reputation points
    2021-03-02T18:41:58.373+00:00

    Here is what you want to avoid win32_product. https://gregramsey.net/2012/02/20/win32_product-is-evil/
    You can use read the computer ARP reg keys to locate office, remember that the CTR stuff is a pain.

    0 comments No comments

  2. Rick Someone 411 Reputation points
    2021-03-02T18:46:12.94+00:00

    I found that out today, and saw the repercussions yesterday.

    Since my script uses

    Get-WmiObject win32_product | where{$_.Name -like "Microsoft Office 365"} | Select-Object -ExpandProperty Version

    How do I use what is recommended, winreg32_addremoveprograms?

    All I need is for PS to find what my Office version is, nd run the PS Update until it equals my $UpdateToVersion

    I sort of had it working yesterday....it upgraded to the current version but then rather than stopping, just was stuck in a loop 'checking for updates' until I CTL/Brk

    I don't use SCCM and my Office is 32b on a 64bit system.

    0 comments No comments

  3. Erin Ding-MSFT 4,456 Reputation points
    2021-03-03T10:39:53.327+00:00

    @Rick Someone

    Could you please provide a complete power shell script?

    What's the update channel of the current version and certain version that you would like to update to? Are they the same?

    From the perspective of Office, as a workaround, you could check the following.

    If their update channel is different, please do the following.

    1. Press Win+R to open Run.
    2. Type gpedit.msc, click OK to open Group Policy.
    3. Navigate to Computer Configuration>Administrative Templates>Microsoft Office 2016(Machine)>Updates>Update Channel, Enable the following policy and then select update channel in it to be the same with certain version.
      73697-image.png
    4. Then type the following command to Run, click OK.

    "C:\Program Files\Common Files\microsoft shared\ClickToRun\OfficeC2RClient.exe" /update user updatetoversion=16.0.13127.xxxx

    73735-image.png

    If their update channel is the same, you could directly try the step 4.


    If an 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.

    0 comments No comments

  4. Rick Someone 411 Reputation points
    2021-03-03T13:14:40.393+00:00

    Well I don't have access to our GPO templates.
    My initial PS was:
    $updatetoversion="16.0.etc"
    2. $version = Get-WmiObject win32_product | where{$_.Name -like "Microsoft Office Professional Plus*"} | Select-Object -ExpandProperty Version
    3. while($version -ne $updatetoversion){
    4. #upgrade the office

    But I read and it was suggested that I not use win32_product, but win32Reg_AddRemovePrograms.
    Then I had no idea how to reword the rest of my script.
    What I have right now is changing #2 and adding on....
    2. $version=Get-ItemProperty "Select * from Win32Reg_AddRemovePrograms where DisplayName like %Microsoft Office 365'" | Delect-Object -ExpandProperty Version

    then I tried to add a while and until (if that's even correct)

    while($version -lt $UpdateToVersion){
    Start-Process $UpdateEXE $UpdateArguments}
    until ($version -ge $UpdateToVersion)|
    break}

    We are all at Semi-Annual so that doesn't come into play. We use 32bit Office on 64bit OS.
    The version to update to is 16.0.13127.21210


  5. sj 0 Reputation points
    2023-05-18T19:30:30.5666667+00:00

    i use a function to pull the ver info so i can use the info in a pipeline

    [cmdletBinding()]
    
    param(
        [Parameter(Mandatory = $True,
            ValuefromPipeline = $True,
            ValuefromPipelineByPropertyName = $True)]
        [validateNotNullorEmpty()]
        [string[]]$ComputerName,
        [Parameter()]
        [ValidateNotNullOrEmpty()]
        [pscredential]$Credential
    )
    
    BEGIN {}
    
    PROCESS{
    
        foreach ($computer in $ComputerName) {
        try {
            $connParams = @{'ComputerName' = $computer }
            if ($PSBoundParameters.ContainsKey('Credential')) {
                $connParams.Credential = $Credential
            }
    
            $psRemotingSession = New-PSSession @connParams
    
            $reg = Invoke-Command -Session $psRemotingSession  {Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Office\ClickToRun\Configuration | select-object VersionToReport,InstallID,CDNBaseUrl,UpdateChannel,UpdateDeadline,pscomputerName}
    
                $output = foreach ( $r in $reg ) {
                if ($reg.CDNBaseUrl -like '*55336b82-a18d-4dd6-b5f6-9e5095c314a6') {Write-Output 'Monthly Enterprise Channel' }
                if ($reg.CDNBaseUrl -like '*64256afe-f5d9-4f86-8936-8840a6a4f5be') {Write-Output 'Current Channel (Preview)' }
                if ($reg.CDNBaseUrl -like '*492350f6-3a01-4f97-b9c0-c7c6ddf67d60') {Write-Output 'Current Channel' }
                if ($reg.CDNBaseUrl -like '*7ffbc6bf-bc32-4f92-8982-f9dd17fd3114') {Write-Output 'Semi-Annual Enterprise Channel' }
                if ($reg.CDNBaseUrl -like '*b8f9b850-328d-4355-9145-c59439a0c4cf') {Write-Output 'Semi-Annual Enterprise Channel (Preview)' }
                if ($reg.CDNBaseUrl -like '*5440fd1f-7ecb-4221-8110-145efaa6372f') {Write-Output 'Beta Channel' }
                }
    
                $props = [ordered]@{'ComputerName' = $reg.pscomputerName;
                    'O365Channel' = $reg.UpdateChannel;
                    'BaseURL' = $reg.CDNBaseUrl;
                    'InstallID' = $reg.InstallID;
                    'O365Version' = $reg.VersionToReport;
                    'Channel' = $output}
    
                $obj = New-Object -TypeName PSObject -Property $props
                Write-Output $obj
    
    
            } catch {$_|out-null}
    
            Get-PSSession | Remove-PSSession
    
        } # end foreach
    }
    
    END {}
    
    0 comments No comments