Solved

Powershell script to list installed software on multiple machines.

Posted on 2013-05-10
6
2,239 Views
Last Modified: 2013-05-15
Hi Guys, im looking to develop the script below further by scanning multiple machines to get the results of installed software. when i run the script it seems to ignore the computers txt files and loops around the same machine. also id like to display the machine name which it has come from.

thanks


$computerfile = get-content "C:\Users\Downloads\computers.txt"
ForEach ($computer in $computerfile) {
Get-WmiObject win32_Product  | Select Name,Version,PackageName,Installdate,Vendor | Sort InstallDate -Descending
}
0
Comment
Question by:cwstad2
  • 3
  • 2
6 Comments
 
LVL 79

Accepted Solution

by:
David Johnson, CD, MVP earned 250 total points
ID: 39156135
change "Get-WmiObject win32_Product"
to "Get-WmiObject win32_Product   -computer $computer"

you just need to add the -computer parameter
0
 
LVL 15

Author Comment

by:cwstad2
ID: 39156221
hi i have tried that and get lots of errors. any ideas? also it doesnt dispaly the computer name

Get-WmiObject : Invalid class
At C:\Users\Downloads\Untitled4.ps1:4 char:14
+ Get-WmiObject <<<<  win32_Product  -computer $computer | Select Name,Version,PackageName,Installdate,Vendor | Sort InstallDate -Descending
    + CategoryInfo          : InvalidOperation: (:) [Get-WmiObject], ManagementException
    + FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.Commands.GetWmiObjectCommand
0
 
LVL 79

Expert Comment

by:David Johnson, CD, MVP
ID: 39156440
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 15

Author Comment

by:cwstad2
ID: 39156539
is there a way to display in the output the machine name?
0
 
LVL 29

Assisted Solution

by:becraig
becraig earned 250 total points
ID: 39156675
Here is an easy way:

$computerfile = get-content "C:\Users\Downloads\computers.txt"
ForEach ($computer in $computerfile) {
@"
=======================
Displaying for $computer
=======================
"@
Get-WmiObject win32_Product  -computername computer | Select Name,Version,PackageName,Installdate,Vendor | Sort InstallDate -Descending
} 

Open in new window


Also to get wmi working on the remote computers you can simply run a scheduled task on multiple servers to run the following command

enable-psremoting -force
0
 
LVL 15

Author Closing Comment

by:cwstad2
ID: 39168435
thanks
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This script checks a path to see if a folder exists. If the folder does exist you will get output "The folder has previously been created. No action taken" If not it will create the folder. Then adds one user modify permission to the folder. It …
This article will help you understand what HashTables are and how to use them in PowerShell.
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question