Compare software on two different domain computers

All,

I found these PowerShell commands on a website to pull a software lists from two separate machines and compare the lists.  My questions are:

1.  Is it possible to automate this with PowerShell ISE?
2.  Can this be scripted so it accepts the domain credentials and both computer names as variables?
3.  Can the output be saved to a network share?  \\servername\myshareddrive, for example.

I have figured out how to run single commands in PowerShell, but I have zero experience with PowerShell ISE and scripting multiple commands.  What would the script look like if this can be accomplished?

 Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object Displ
ayName, DisplayVersion, Publisher, InstallDate | Format-Table –AutoSize > C:\Users\User1\Documents\InstalledPrograms
-PS.txt

 Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object Displ
ayName, DisplayVersion, Publisher, InstallDate | Format-Table –AutoSize > C:\Users\User2\Documents\InstalledPrograms-PS2.txt

 Compare-Object -ReferenceObject (Get-Content C:\Users\User2\Documents\InstalledPrograms-PS.txt) -DifferenceObje
ct (Get-Content C:\Users\SavedToNetworkShare\Documents\InstalledPrograms-PS2.txt)

Open in new window

LVL 7
Brad Sims, CCNACyberSecurity AnalystAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AlanConsultantCommented:
Hi Brad,

I am not at a machine where I can test this right now, but I would suggest a script something like this:

ForEach ($Computer in Get-ADComputer -Filter *)
{
	Get-WMIObject -ComputerName $Computer -Class Win32_Product
}

Open in new window



Hope that helps at least move you in the right direction.


Alan.
0
AlanConsultantCommented:
Hi Brad,

I just remembered seeing a script to do this already, and I found it on TechNet:

https://gallery.technet.microsoft.com/scriptcenter/Get-Software-Function-to-bd2e0204

Appears to be exactly what you need - run it against each of the machines and compare the outputs.

I note they suggest not using the Win32_Product class, so please ignore my previous post.


Alan.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Brad Sims, CCNACyberSecurity AnalystAuthor Commented:
Got this to work at home.  Unfortunately they blocked PowerShell scripts at work so I'm fighting that battle with them now by trying to show them the time savings.  Thanks for the script though.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.