none
Script to view installed software on remote server RRS feed

  • Question

  • Hello scripting guy,

    I have a question regarding a script that uses conditional statements and comparison operators to query remote servers for installed software.

    I am using PS on server 2016, but I am getting errors using the command get-wmiobject.

    I believe PS command "get-wmiobject" is deprecated on windows server 2016,  so I am searching an alternative script for viewing listed software.

    For example, script below works.
    Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* |  Select-Object DisplayName, DisplayVersion, Publisher, InstallDate |Format-Table –AutoSize

    But when I add the "Get-ItemProperty..." commands into my script, it does nothing...
    Below is my current script that does not show installed software on a remote server:
        if ($testingconnection -eq 'True')

         {    Write-Host "$computer is up" -ForegroundColor Green 

         $getsoftware = Invoke-Command -cn servername -ScriptBlock {Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | select DisplayName, Publisher, InstallDate 
         if ($getsoftware.Count -eq '')
         {Write-Host "$computer has google installed"}

         else{Write-Host "$computer does not have google installed" }

         }

         }



    Can you please offer some advice on how to get the get-item command to work with my script?
    Thanks
    Sandro Gia

                  
    Wednesday, November 20, 2019 11:02 PM

All replies

  • There are numerous scripts in the Gallery that will get this. "Deprecated" does not mean unusable.

    The replacement for Get-WmiObject is Get-CimInstance.

    Get-CimInstance Win32_Product -Computername remotepc


    \_(ツ)_/

    Wednesday, November 20, 2019 11:50 PM
  • what does   if ($getsoftware.Count -eq '') mean?

    my blog: http://shserg.ru/

    Thursday, November 21, 2019 6:44 AM
  • Not legitimate code. A number is not a string so it is pretty useless.

    The code you posted above is pretty bad.  Perhaps you should try to find a better example or take some time to learn PowerShell.


    \_(ツ)_/

    Thursday, November 21, 2019 8:53 AM
  • Hi,

    I have been searching for the easiest method to view installed software on a remote server, it seems that using the registry is a common method for doing this.

    >Get-CimInstance Win32_Product -Computername server does not show any results so far.

    Thanks for your feedback.

    Thursday, November 21, 2019 6:08 PM
  • Please ignore my last comment, the get-ciminstance started working after I ran an update:

    Get-CimInstance -ClassName Win32_ComputerSystem -ComputerName server

    Thursday, November 21, 2019 6:21 PM