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.
    • T
      Texkonc
      last edited by scottalanmiller

      I can run this just fine and it screen outputs like a champ

      Get-Content -Path c:\scripts\Computers.txt | ForEach-Object {Get-WmiObject -Class Win32_Product -ComputerName $_} |  Format-Table Name,Vendor,Version,Caption,LocalPackage
      

      Then when I add:
      Get-Content -Path c:\scripts\Computers.txt | ForEach-Object {Get-WmiObject -Class Win32_Product -ComputerName $} | Format-Table Name,Vendor,Version,Caption,LocalPackage |Where-Object -FilterScript {$.Name -like "Microsoft Office*"}
      To only find Microsoft Office, it just completes and does no screen output

      Get-Content -Path c:\scripts\Computers.txt | ForEach-Object {Get-WmiObject -Class Win32_Product -ComputerName $_} | Format-Table Name,Vendor,Version,Caption,LocalPackage | Export-CSV -NoTypeInformation "C:\scripts\installed.csv";
      This returns a file with just guid only or blank in testing

      Trying to run this in an AD domain to get Microsoft Office installs and versions for prep of a O365 migration.
      So I would like the format of the top one formatted into CSV and remove the other crap and just list me "Microsoft Office*"

      coliverC 1 Reply Last reply Reply Quote 3
      • MattSpellerM
        MattSpeller
        last edited by

        Could you put your code in via the form that removes all the markup? It's messing with my ability to help ya.

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

          Once I figure out how

          scottalanmillerS 1 Reply Last reply Reply Quote 0
          • scottalanmillerS
            scottalanmiller @Texkonc
            last edited by

            @Texkonc said in Powershell: Get Office Software:

            Once I figure out how

            Just start a line with four spaces.

            Or use back ticks, three of them, on the line before and after the code.

            T 2 Replies Last reply Reply Quote 0
            • T
              Texkonc @scottalanmiller
              last edited by Texkonc

              This post is deleted!
              1 Reply Last reply Reply Quote 0
              • T
                Texkonc @scottalanmiller
                last edited by

                @scottalanmiller said in Powershell: Get Office Software:

                @Texkonc said in Powershell: Get Office Software:

                Once I figure out how

                Just start a line with four spaces.

                Or use back ticks, three of them, on the line before and after the code.

                No Dice
                and What?

                scottalanmillerS 1 Reply Last reply Reply Quote 0
                • coliverC
                  coliver @Texkonc
                  last edited by coliver

                  Get-Content -Path c:\scripts\Computers.txt | ForEach-Object {Get-WmiObject -Class Win32_Product -ComputerName $_} |  Format-Table Name,Vendor,Version,Caption,LocalPackage
                  Get-Content -Path c:\scripts\Computers.txt | ForEach-Object {Get-WmiObject -Class Win32_Product -ComputerName $_} |  Format-Table Name,Vendor,Version,Caption,LocalPackage |Where-Object -FilterScript {$_.Name -like "*Microsoft Office**"} 
                  Get-Content -Path c:\scripts\Computers.txt | ForEach-Object {Get-WmiObject -Class Win32_Product -ComputerName $_} |  Format-Table Name,Vendor,Version,Caption,LocalPackage
                  

                  or

                  Get-Content -Path c:\scripts\Computers.txt | ForEach-Object {Get-WmiObject -Class Win32_Product -ComputerName $_} | Format-Table Name,Vendor,Version,Caption,LocalPackage

                  Get-Content -Path c:\scripts\Computers.txt | ForEach-Object {Get-WmiObject -Class Win32_Product -ComputerName $_} | Format-Table Name,Vendor,Version,Caption,LocalPackage |Where-Object -FilterScript {$_.Name -like "*Microsoft Office**"}

                  Get-Content -Path c:\scripts\Computers.txt | ForEach-Object {Get-WmiObject -Class Win32_Product -ComputerName $_} | Format-Table Name,Vendor,Version,Caption,LocalPackage | Export-CSV -NoTypeInformation "C:\scripts\installed.csv";

                  1 Reply Last reply Reply Quote 0
                  • momurdaM
                    momurda
                    last edited by

                    Hi
                    Have you looked at this.
                    https://msdn.microsoft.com/en-us/library/bb977556.aspx
                    MAP
                    THis seems to be a tool from MS that does what you want.

                    momurdaM 1 Reply Last reply Reply Quote 0
                    • scottalanmillerS
                      scottalanmiller @Texkonc
                      last edited by

                      @Texkonc said in Powershell: Get Office Software:

                      @scottalanmiller said in Powershell: Get Office Software:

                      @Texkonc said in Powershell: Get Office Software:

                      Once I figure out how

                      Just start a line with four spaces.

                      Or use back ticks, three of them, on the line before and after the code.

                      No Dice
                      and What?

                      How did it not work? Just put four spaces in front of your code.

                      1 Reply Last reply Reply Quote 0
                      • scottalanmillerS
                        scottalanmiller
                        last edited by

                        I just did it as an example. You can't have it still tied to the line above, you need to hit enter to separate it. The way that you had it, it was four spaces between that line and the line before, it wasn't a line on its own yet.

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

                          I'm not sure of your end goal, so this way of querying the office version may not suit your needs... but here it is anyways:

                          I query the registry to find the version of office on a PC in some scripts:

                          reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\O365ProPlusRetail - en-us" /v DisplayVersion
                          
                          reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\O365ProPlusRetail - en-us" /v DisplayName
                          

                          And if you like to get dirty:

                          reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" /s /f *Office*
                          
                          T 1 Reply Last reply Reply Quote 0
                          • momurdaM
                            momurda @momurda
                            last edited by

                            @momurda
                            I just tried using the MAP toolkit from MS as i thought it would be a useful inventory tool. You know, since MS makes their money selling software, you would think they would make a tool that would let you inventory their software and tell you license info.
                            It is just another half assed .exe from MS that really does nothing useful.
                            It tells you how many pcs you have that are 'ready' for a certain product, not what is currently installed, no license keys, nothing useful.
                            Seriously what is the point of this?

                            T scottalanmillerS 2 Replies Last reply Reply Quote 1
                            • T
                              Texkonc @momurda
                              last edited by

                              @momurda said in Powershell: Get Office Software:

                              @momurda
                              I just tried using the MAP toolkit from MS as i thought it would be a useful inventory tool. You know, since MS makes their money selling software, you would think they would make a tool that would let you inventory their software and tell you license info.
                              It is just another half assed .exe from MS that really does nothing useful.
                              It tells you how many pcs you have that are 'ready' for a certain product, not what is currently installed, no license keys, nothing useful.
                              Seriously what is the point of this?

                              Shocker...

                              1 Reply Last reply Reply Quote 0
                              • scottalanmillerS
                                scottalanmiller @momurda
                                last edited by

                                @momurda said in Powershell: Get Office Software:

                                @momurda
                                I just tried using the MAP toolkit from MS as i thought it would be a useful inventory tool. You know, since MS makes their money selling software, you would think they would make a tool that would let you inventory their software and tell you license info.
                                It is just another half assed .exe from MS that really does nothing useful.
                                It tells you how many pcs you have that are 'ready' for a certain product, not what is currently installed, no license keys, nothing useful.
                                Seriously what is the point of this?

                                Making licensing easy makes it hard to oversell.

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

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

                                  black3dynamiteB 1 Reply Last reply Reply Quote 0
                                  • 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
                                            • 1
                                            • 2
                                            • 1 / 2
                                            • First post
                                              Last post