Compiling a List of Installed Programs on Remote Computers

Various techniques exist for executing PowerShell commands on remote machines. May I ask how I can retrieve a list of installed applications from a set of remote servers?

Question:

My aim is to obtain the GUID of each program installed on approximately 150 computers. To accomplish this, I considered developing a login script that would execute a script and save the output to a shared folder on a server. Despite the script running, the output file remains empty. However, when I execute the script manually, it works successfully. I have created two scripts: one at
batch file
and the other in PowerShell.


Batch File

wmic product get > \svrPublicDiagnostics%computername%-installed-programs.txt


Powershell

$properties = "identifyingnumber","name","vendor","version"
$ComputerName = $env:computername
Get-WmiObject -Class win32_Product -Property $properties |             
Select -Property $properties |             
Export-Csv -Path \svrPublicDiagnostics$ComputerName-Installed-Programs.csv -Encoding Unicode -NoTypeInformation

The specified location permits the user to write.

Do you have any explanation for why this is not functioning? Additionally, I am receptive to alternative recommendations.


Solution 1:

This question has been asked before, but when responding using

WMIC

, please use the following code.


wmic /node:server

for remote machines.

The PowerShell command

Get-WMIObject

includes the option

-ComputerName

that enables you to execute it on a computer that is not local.

Try:

Get-WMIObject -Class Win32_Product -ComputerName RemoteMachine101


Solution 2:


After identifying the issue, here is the course of action I took.

Initially, I included a GPO in the computer configuration that permitted WMI-In. This resolved the issue of receiving the “unavailable” message for ”
RPC server
“.

Following an IP scan using Angry IP on all available nodes, I filtered the list using
IP addresses
and exported it to a
CSV file
format. Finally, the filtered list was saved as a text file.

Following this, a PowerShell script was generated to retrieve the
IP address
from the previously created txt file. This script will execute each IP address and store the outcome in individual files. The script is shown below:

$IPAddress = Get-Content Z:Installed-Softwareip-addresses.txt
foreach($ComputerName in $IPAddress) { 
echo $ComputerName
Get-WmiObject -Class Win32_Product -ComputerName $ComputerName | Select-Object Name, IdentifyingNumber | Export-Csv C:Installed-Software$ComputerName-installed-programs.csv }

Instead of scanning the entire subnet, I opted to scan and execute the script only on the available nodes. To save time, I eliminated the offline nodes since generating the results takes approximately a minute or two.

I hope this proves useful to someone. I want to give a special thanks to user4317867 for their encouragement.


Solution 3:


The use of Win32_product can lead to undesired outcomes in terms of endpoint and network bandwidth. This is due to the fact that when MSI files are executed, they conduct an integrity and compatibility assessment based on the system architecture, resulting in slower speeds and reduced pipe capacity. To avoid this, one can opt for the uninstall registry as a viable alternative. If string and path parsing seem daunting, using “Gwmi win32_addremoveprograms -computer | select *” is a great option.

Although it may not resolve the RPC error, it’s still important to mention the differences between “product” and other alternatives. Best of luck!

Frequently Asked Questions