ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Powershell: Get Office Software

    IT Discussion
    8
    29
    3.9k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • black3dynamiteB
      black3dynamite @Texkonc
      last edited by

      @Texkonc said in Powershell: Get Office Software:

      @Tim_G said in Powershell: Get Office Software:

      And if you like to get dirty:

      reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" /s /f *Office*
      

      The best one, but need to run it against remote machines. Issue with this one, is not all machines might not have remote registry on. Hence a WMI call is better.

      You do something like this.

      Invoke-Command -ComputerName HOSTNAME -Credential domain\username `
      -ScriptBlock {
      cmd /k reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" /s /f Office
      }

      T 1 Reply Last reply Reply Quote 1
      • T
        Texkonc @black3dynamite
        last edited by

        @black3dynamite said in Powershell: Get Office Software:

        @Texkonc said in Powershell: Get Office Software:

        @Tim_G said in Powershell: Get Office Software:

        And if you like to get dirty:

        reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" /s /f *Office*
        

        The best one, but need to run it against remote machines. Issue with this one, is not all machines might not have remote registry on. Hence a WMI call is better.

        You do something like this.

        Invoke-Command -ComputerName HOSTNAME -Credential domain\username `
        -ScriptBlock {
        cmd /k reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" /s /f Office
        }

        I have about 50 machines, I am not going to enter the host name everytime, I need it to pull from a list.

        1 Reply Last reply Reply Quote 0
        • ObsolesceO
          Obsolesce
          last edited by Obsolesce

          I spent a decent amount of time on this out of curiosity and finally got something together that I actually tested with various domain PCs, and works:

          $computers = Get-Content -Path C:\computers.txt
          ForEach ($computer in $computers)
          {
              Invoke-Command -ComputerName $computer -ErrorAction SilentlyContinue {Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate | Where-Object {$_.DisplayName -like '*Microsoft Office*'} | Export-CSV -NoTypeInformation "C:\test.csv"}
          }
          

          I suppose you can figure out how to change it to what will work in your environment if you have issues connecting to computers. This should get you going.

          black3dynamiteB 1 Reply Last reply Reply Quote 2
          • T
            Texkonc
            last edited by

            That is a great script.
            I ran it on a 2012 nonR2 and a 2008R2, and my desktop win10. I can not get it to write the output to a file on any of the 3. If I comment out the output to a file, it screen prints fine.

            1 Reply Last reply Reply Quote 0
            • black3dynamiteB
              black3dynamite
              last edited by black3dynamite

              Try this.

              $computers = Get-Content -Path C:\computers.txt
              ForEach ($computer in $computers)
              {
                  $results = Invoke-Command -ComputerName $computer -ErrorAction SilentlyContinue {
                  Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\* -ErrorAction SilentlyContinue | `
                  Select-Object DisplayName, DisplayVersion, Publisher, InstallDate | `
                  Where-Object {$_.DisplayName -like '*Microsoft Office*'}
                  }
               $results | Export-Csv -NoTypeInformation -Path "C:\test.csv"
              }
              1 Reply Last reply Reply Quote 1
              • T
                Texkonc
                last edited by

                @black3dynamite said in Powershell: Get Office Software:

                $computers = Get-Content -Path C:\computers.txt
                ForEach ($computer in $computers)
                {
                $results = Invoke-Command -ComputerName $computer -ErrorAction SilentlyContinue {
                Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall* -ErrorAction SilentlyContinue | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate |
                Where-Object {$_.DisplayName -like 'Microsoft Office'}
                }
                $results | Export-Csv -NoTypeInformation -Path "C:\test.csv"
                }

                That creates the file, but the file ends up blank

                ObsolesceO 1 Reply Last reply Reply Quote 0
                • black3dynamiteB
                  black3dynamite @Obsolesce
                  last edited by

                  @Tim_G said in Powershell: Get Office Software:

                  I spent a decent amount of time on this out of curiosity and finally got something together that I actually tested with various domain PCs, and works:

                  $computers = Get-Content -Path C:\computers.txt
                  ForEach ($computer in $computers)
                  {
                      Invoke-Command -ComputerName $computer -ErrorAction SilentlyContinue {Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate | Where-Object {$_.DisplayName -like '*Microsoft Office*'} | Export-CSV -NoTypeInformation "C:\test.csv"}
                  }
                  

                  I suppose you can figure out how to change it to what will work in your environment if you have issues connecting to computers. This should get you going.

                  The test.csv file ends up showing up on each computer.

                  ObsolesceO 1 Reply Last reply Reply Quote 0
                  • ObsolesceO
                    Obsolesce @black3dynamite
                    last edited by

                    @black3dynamite said in Powershell: Get Office Software:

                    @Tim_G said in Powershell: Get Office Software:

                    I spent a decent amount of time on this out of curiosity and finally got something together that I actually tested with various domain PCs, and works:

                    $computers = Get-Content -Path C:\computers.txt
                    ForEach ($computer in $computers)
                    {
                        Invoke-Command -ComputerName $computer -ErrorAction SilentlyContinue {Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate | Where-Object {$_.DisplayName -like '*Microsoft Office*'} | Export-CSV -NoTypeInformation "C:\test.csv"}
                    }
                    

                    I suppose you can figure out how to change it to what will work in your environment if you have issues connecting to computers. This should get you going.

                    The test.csv file ends up showing up on each computer.

                    Yeah change the path to a network location.

                    1 Reply Last reply Reply Quote 1
                    • ObsolesceO
                      Obsolesce @Texkonc
                      last edited by

                      @Texkonc said in Powershell: Get Office Software:

                      @black3dynamite said in Powershell: Get Office Software:

                      $computers = Get-Content -Path C:\computers.txt
                      ForEach ($computer in $computers)
                      {
                      $results = Invoke-Command -ComputerName $computer -ErrorAction SilentlyContinue {
                      Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall* -ErrorAction SilentlyContinue | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate |
                      Where-Object {$_.DisplayName -like 'Microsoft Office'}
                      }
                      $results | Export-Csv -NoTypeInformation -Path "C:\test.csv"
                      }

                      That creates the file, but the file ends up blank

                      You need to include the stars on each side of 'Microsoft Office'

                      ObsolesceO 1 Reply Last reply Reply Quote 0
                      • ObsolesceO
                        Obsolesce
                        last edited by

                        I made a few changes, mainly appending data output to a central CSV file:

                        $computers = Get-Content -Path "C:\computers.txt"
                        ForEach ($computer in $computers)
                        {
                            Invoke-Command -ComputerName $computer -ErrorAction SilentlyContinue -ScriptBlock {Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate | Where-Object {$_.DisplayName -like '*Microsoft Office*'} | Export-CSV -NoTypeInformation -Append -Path "\\YOURCOMPUTER\c$\test.csv"}
                        }
                        
                        1 Reply Last reply Reply Quote 0
                        • ObsolesceO
                          Obsolesce @Obsolesce
                          last edited by

                          @Tim_G said in Powershell: Get Office Software:

                          @Texkonc said in Powershell: Get Office Software:

                          @black3dynamite said in Powershell: Get Office Software:

                          $computers = Get-Content -Path C:\computers.txt
                          ForEach ($computer in $computers)
                          {
                          $results = Invoke-Command -ComputerName $computer -ErrorAction SilentlyContinue {
                          Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall* -ErrorAction SilentlyContinue | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate |
                          Where-Object {$_.DisplayName -like 'Microsoft Office'}
                          }
                          $results | Export-Csv -NoTypeInformation -Path "C:\test.csv"
                          }

                          That creates the file, but the file ends up blank

                          You need to include the stars on each side of 'Microsoft Office'

                          Nevermind, the website uses it as italics.

                          JaredBuschJ 1 Reply Last reply Reply Quote 0
                          • JaredBuschJ
                            JaredBusch @Obsolesce
                            last edited by

                            @Tim_G said in Powershell: Get Office Software:

                            @Tim_G said in Powershell: Get Office Software:

                            @Texkonc said in Powershell: Get Office Software:

                            @black3dynamite said in Powershell: Get Office Software:

                            $computers = Get-Content -Path C:\computers.txt
                            ForEach ($computer in $computers)
                            {
                            $results = Invoke-Command -ComputerName $computer -ErrorAction SilentlyContinue {
                            Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall* -ErrorAction SilentlyContinue | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate |
                            Where-Object {$_.DisplayName -like 'Microsoft Office'}
                            }
                            $results | Export-Csv -NoTypeInformation -Path "C:\test.csv"
                            }

                            That creates the file, but the file ends up blank

                            You need to include the stars on each side of 'Microsoft Office'

                            Nevermind, the website uses it as italics.

                            Escape them with a backslash

                            You need to include the stars on each side of '*Microsoft Office*'

                            or put them in single backticks.
                            You need to include the stars on each side of '*Microsoft Office*'
                            0_1494560735860_upload-902947ef-5a28-4d7c-a63b-dad58fc57665

                            1 Reply Last reply Reply Quote 1
                            • T
                              Texkonc
                              last edited by Texkonc

                              This one fit my needs for now.
                              ///
                              Get-Content -Path c:\scripts\Computers.txt | ForEach-Object {Get-WmiObject -Class Win32_Product -ComputerName $} | select-object PSComputerName,Name,Vendor,Version | Where-Object {$.Name -like "Microsoft Office"} | out-file c:\scripts\installed.txt
                              ///

                              1 Reply Last reply Reply Quote 2
                              • T
                                Texkonc
                                last edited by Texkonc

                                Get-Content -Path c:\scripts\Computers.txt | ForEach-Object {Get-WmiObject -Class Win32_Product -ComputerName $_} | select-object PSComputerName,Name,Vendor,Version | Where-Object {$_.Name -like "*Microsoft Office*"} | Format-Table PSComputerName,Name,Vendor,Version -Wrap -Auto | out-file c:\scripts\installed.txt
                                

                                Updated. Management Framework 3 or higher required

                                1 Reply Last reply Reply Quote 2
                                • 1
                                • 2
                                • 2 / 2
                                • First post
                                  Last post