06 May,2014 by Tom Collins
Question: How can I list all software installed on a server using Powershell? I’d also like to compare two servers and report on differences of software installed using Powershell.
Answer: To list the software installed on server use the Powershell management cmdlet Get-WmiObject -Class Win32_Product .
To compare two servers use the output from the Powershell cmdlet Get-WmiObject -Class Win32_Product and then use the Powershell utility cmdlet Compare-Object –ReferenceObject to compare the output.
This example illustrates how to create the output
Step 1 : Create the output for the two servers. Execute this code on the two separate servers. Example 1 outputs to the Powershell GUI. Example 2 , outputs to an output file.
--Example 1 – output to GUI Get-WmiObject -Class Win32_Product | Select-Object -Property name,installdate | sort-object -property installdate --Example 2 – output to output file Get-WmiObject -Class Win32_Product | Select-Object -Property Name > C:\path\server1.txt
Step 2 : Using the two output files , execute this Powershell script
Compare-Object -ReferenceObject (Get-Content C:\server1.txt) -DifferenceObject (Get-Content server2.txt)
Example out from the Compare-Object -ReferenceObject
Read More
SQL Server Database Size and Free Disk Space Daily Report
Powershell Scripts for DBA - SQL Server DBA
Powershell to HTML - SQL Server DBA
This is only a preview. Your comment has not yet been posted.
As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.
Having trouble reading this image? View an alternate.
Posted by: |