PowerShell's ability to gather installed software on remote systems

This topic contains 5 replies, has 4 voices, and was last updated by  Aaron Jensen 3 years, 2 months ago.

  • Author
    Posts
  • #11550

    William Davis
    Participant

    I am fairly new to all CLI's. I have messed around in Linux, DOS, and would not consider myself very good in either. Then I became interested in PowerShell, and I am hooked. I always wanted to be able to use a CLI, and a scripting language and I decided that PowerShell will be my target. Anyway, on to the question I have.

    I have used the win32_product call against remote machines and it works very well, but the other day the boss ask me to run a product query and looking for "Mozilla Firefox". The wmi-object did not find "Mozilla" at all. That stuck me a very strange. I then read that the better way to find all software for sure is through the registry. My problem is trying to build a script that will use the registry and can be run against remote machines from a text file. I am new, so I read and dismantle already written scripts to see what makes them run, I learn really well like that. So if someone could provide some pointers, I really would appreciate them, thanks and from a retired soldier, SALUTE!

  • #11552

    Chris Stephens
    Participant

    You will want to create your basic query using either win32_product or the registry as you specified. There is also a great recent article about this ("http://blogs.technet.com/b/heyscriptingguy/archive/2013/11/15/use-powershell-to-find-installed-software.aspx").

    Once you have the basic query complete, you would get the list of machines from your text file and pipe them into the query:

    Get-Content 'c:\computerlist.txt' | ForEach-Object { Get-WMIObject -ComputerName $_ -Query "SELECT * FROM win32_product WHERE name LIKE '%firefox%'" | Select-Object -Property $_,Name,InstallLocation,InstallDate | Export-CSV 'c:\computerqueryresults.csv'

  • #11568

    William Davis
    Participant

    Thanks so much, I will explore the site you sent and provide feedback. I can get it to work using win32_product. It will not find all the software, any idea why that happens? Why do we need to use the registry approach? My problem is getting the registry to query remote domain machines, I just have not mastered that method yet. Thanks for taking the time to guide me, SALUTE!

  • #11590

    William Davis
    Participant

    Okay sir, another question as it pertains to remoting. I have watched the MVA PowerShell video concerning remoting and I can say that it is awesome capability. I do have a particular situation as I work for the DoD. I found out yesterday that there is no way that the SA's are going to allow the WinRM service to be pushed to "ON". They claim that the Information Assurance folks have a ban against WinRM and have directed for it to remain OFF. I can set it machine by machine as we build the image's but then those machines would pop hot for non-compliance, and you can guess the mess that would make. So, for the time being, it looks like that I will not be allowed to use this awesome tool. My question to you is: Is there another way to gather info without using WinRM, other that the WMI-OBJECT? I can get lots of stuff from a "one-to-many" approach, but I am just picking your head for any other technique's that you might know of. Once again, thanks so much for your time, SALUTE! By the way, this is a great site for us newbies to just ask questions, hope you don. t mind lots of questions.

  • #18617

    Joseph Kern
    Participant

    William, I can feel your pain ... Imagine the shock that your IA guys will have when they find out that Server 2012 server administration tools require winrm ... 🙂

  • #18659

    Aaron Jensen
    Participant

    The registry approach is recommended because it performs much better than WMI and returns more data. Querying via WMI will also cause the Windows installation platform/framework/whatever to do a consistency check on all installed software. (Just check out the Windows Event Log.)

    Shameless self-promotion: my Carbon module contains a Get-PrograminstallInfo, which queries the registry to find all installed software. it's fast and looks like a text-based Programs and Features. You can view the source code for Get-ProgramInstallInfo on Bitbucket.

You must be logged in to reply to this topic.