How to know the installed Software version in PowerShell - powershell

I wanted to know what version of software(say X software) installed in my system with PowerShell. In my case, I wanted to know what version of Service Fabric SDK installed in my system with PowerShell.

if your process/software is run , use this command :
Get-Process -Name "xsoftware" | Format-list -Property ProductVersion

In our case, we needed to verify if MongoDB was installed on multiple servers, and if so, what version. We used a simple PowerShell command and pushed it out multiple servers via Ansible/AWX. Here's the command:
Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object {$_.DisplayName -like "*MongoDB*"} | Select-Object DisplayName, DisplayVersion, InstallDate | Format-List;

This link highlight very well what the issues are with using the WMI approach and then outlines a solution for using the registry. The way he does the registry also allows for calling it against remote machines.
https://mcpmag.com/articles/2017/07/27/gathering-installed-software-using-powershell.aspx

You can use WMI to get information of an installed product. To do this filter by the Name. For example, to get information of Word:
$product = gwmi win32_product -filter "Name LIKE '%Word%'"
You will then find the version information in the Version property:
$product.Version
NOTE: The WMI lookups can be a bit slow, so be patient!

Related

Generate a list of App Pool Virtual Path authentication settings using PowerShell?

I have been looking at all the PowerShell commands like Select-WebConfiguration, Get-WmiObject, Get-IISAppPool to generate a list of the enabled App Pool authentication settings for all the app pools on my servers. We have like 10 servers and a dozen+ app pools on each and want to find a quick way to check settings. Checked a lot on the web and haven't been able to find a command to generate a nice neat listing.
If you want to get the iis application pool identity then you could try the below command:
Import-Module WebAdministration;Get-ChildItem -Path IIS:\AppPools\ |
Select-Object name, #{e={$_.processModel.username};l="username"}, <##{e={$_.processModel.password};l="password"}, #> #{e={$_.processModel.identityType};l="identityType"} |
format-table -AutoSize
I was able to piece this together below and it seemed to work. Once last thing I am trying to figure out is how to use this same command to query remote servers
Get-WebConfiguration system.webServer/security/authentication/* -Recurse | where {$_.enabled -eq $true} | Sort-Object location,itemxpath | Select location,itemxpath,enabled | format-table -AutoSize
I found out that to run this command on another machine you use the command enter-pssession and the server name. It does not provide any switches that allow you to run them on another server.

Powershell query - Querying computer for listed Programs and filtering

I'm hoping you all can help me with this. I'm trying to use PowerShell to see what software is currently installed on a machine, but i want results of specific software not the entire library of installed software if that makes sense? Note - I'm new to PowerShell and I'm doing my best to learn and learn how to use/create scripts. I've tried Google!
I'm using the following to query a computer on the local network and i get a result of all software listed.
Get-Wmiobject -class Win32_product -computername "PC1" | Select-Object name,version
Could someone help me filter the results for specific software? I also want to see the version of the software.
Any help would be appreciated! It'll certainly help towards my learning.
There are two ways to do it.
if you know what application you looking for, you can use the following:
Get-Wmiobject -class Win32_product -filter "name='Application Name'" | Select-Object name,version
Take note that it must be the same (no case sensitive)
if you are looking for a pattern you can use the following (which is longer to execute):
Get-Wmiobject -class Win32_product | Select-Object name,version | where {$_.Name -like "*Google*"}
you can add the -ComputerName parameter if you need.
let me know how it worked for you.

get-wmiobject script not working

I am trying to write a script to pull software list down from multiple computers in one script, however most is working but one field is not pulling through anything
I have got this script below...
GET-WMIOBJECT -CLASS WIN32_PRODUCT -COMPUTER CLUKxxx,CLUKyyy,CLUKzzz | SELECT-OBJECT COMPUTERNAME, NAME, VERSION, VENDOR | SORT OBJECTNAME | EXPORT-CSV "C:\CLUKxxx_yyy_zzz_Programs.csv"
the name, version and vendor is pulling through just fine, however I cannot seem to find a way to pull through the computer name. I have tried _SERVER, COMPUTER, COMPUTERNAME, SERVER but nothing is working.
I know the script is working pulling through software from both computers as I got duplicate program names in the list (i.e. IBM Notes comes up twice).
Does anyone know how I can put the computer name in the script?
So far, COMPUTERNAME column is appearing blank.
Thanks guys.
Dan
Use the PsComputerName property of WMI objects. Change your script to -
GET-WMIOBJECT -CLASS WIN32_PRODUCT -COMPUTER CLUKxxx,CLUKyyy,CLUKzzz | SELECT-OBJECT PsCOMPUTERNAME, NAME, VERSION, VENDOR

Find NIC by IP address

I need to be able to find a NIC by IP address, whether full or partial. So writing something like:
Get-NIC-By-IP 10.10.*
Could return:
Ethernet
I know how to do this in Bash but haven't been able to find a PowerShell solution to this.
For versions of Windows and/or PowerShell that do not support Get-NetIPAddress, you can get the requisite information with a combination of the WMI queries for the classes Win32_NetworkAdapterConfiguration and Win32_NetworkAdapter:
$Configs = Get-WMIObject -Class Win32_NetworkAdapterConfiguration -Filter "IPEnabled='TRUE'" | Where-Object {$_.IPAddress -like "192.168.*"}
ForEach ($Config in $Configs) {
Get-WMIObject -Class Win32_NetworkAdapter -Filter "Index=$($Config.Index)" | Select-Object NetConnectionID,Description
}
By using the following command you will receive every interface which matches the IP-addres which you mention in the match clause.
Get-NetIPAddress | ?{ $_.AddressFamily -eq "IPv4" -and ($_.IPAddress -match "192.")} | Select-Object InterfaceAlias
In my case this is:
InterfaceAlias
--------------
Ethernet 2
Ethernet
Of course, you can modify the output if necessary.
Supplement for old OS'es
You can't run this script on old Windows browsers as the cmdlet isn't included according to this thread on TechNet: https://social.technet.microsoft.com/Forums/office/en-US/dcc966a1-24c2-4ae4-b39d-b78df52b6aef/install-of-powershell-3-on-windows-7-seems-to-be-missing-modules?forum=winserverpowershell
There are many cmdlets in Powershell for Windows 8 and Server 2012 (PS V3) that are not included in the V3 release for Windows 7.  An example would be Get-NetIPAddress, and many other network-related cmdlets.
Then again, it might be a good idea to upgrade the OS to a supported version (if possible of course).

How do I (un)install an application remotely using PowerShell 2.0?

I understand how to use PowerShell to install/uninstall locally, but how can I run this on another server that is on the same network and same OS version?
$product = Get-WmiObject -Class Win32_Product -Filter "Name='MyMSI'"
$product.Uninstall()
or
$product = Get-WmiObject -List | ?{ $_.Name -eq "Win32_Product" }
$product.Install("C:\\MyMSI.msi")
You can still use those lines to uninstall and install software by using the -ComputerName property and specifying the name of the computer. For the install you have to copy the software to the local filesystem and specify that in the command.
You must use PowerShell remoting.
Read this please