Get-WmiObject -Class Win32_Product - showing wrong version of program - powershell

Get-WmiObject -Class Win32_Product | where-object { $_.name -like "*OfficeScan*" }
Shows me the wrong version number of the TrendMicro OfficeScan Client - the default Version 12.0.1222 when the installed version is 12.0.4430.
I also tried:
Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate
There it doesnt show up at all. It's weird because in the old systemcontrol if i go to deinstallation it shows the correct version:
So I need to somehow extract the information of the actual version to my powershell. I need it for a auto update feature, it has to be using powershell.

Assuming you're using a 64bit system, you're looking in the wrong place in the registry.
I don't have TrendMicro, so using Adobe Reader as an example:
Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* |
Where-Object { $_.DisplayName -like "*Adobe Reader*" } |
Select-Object DisplayName, DisplayVersion
If you just want a numerical Version property to use as a comparison, update:
Select-Object -Expand DisplayVersion

Related

Get ADcomputer Buil windows extend

I wanted to know if I can retrieve via script or powershel command the extended build of windows in order to make a report of the computers which received the last patch and those which are in later version
What i want
for the moment I found this command but I only get the windows build
It only allows me to know which version of windows 10 the computers have
Get-ADComputer -Filter * -Properties OperatingSystemVersion | Select-Object -Prperty Name, OperatingSystemVersion
Thanks
try this:
get-ADComputer -Filter * -Properties OperatingSystemVersion, operatingSystem, name | #
Where-Object {($_.operatingSystem -like "Windows*")} |
Select-Object name, OperatingSystemVersion | sort name #or OperatingSystemVersion
If you want a build version:
(Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name "UBR").UBR
By
Invoke-Command -ComputerName name -ScriptBlock {}

How to get a program's installation path using Powershell

I've tried to use Get-ChildItem to get installed program property information and it does provide some of the information I require but the Installed Location/path is usually blank. Given a program's name/displayname, is there a way reliable way to get the installation path of a Windows Server program (remote to other servers) using Powershell?
Thanks in advance.
Using Registry:
Get-ChildItem HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall |
% { Get-ItemProperty $_.PsPath } | Select DisplayName,InstallLocation
Using WMI:
Get-WmiObject -Class Win32_Product -Filter 'Name like "%Microsoft Office%"' |
Select Caption,InstallLocation
For Remoting, Through registry it's totally different story, with WMI just add the -ComputerName Parameter (and make sure you have permissions)
These 2 cmdlets:
Get-ChildItem HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\* | % { Get-ItemProperty $_.PsPath } | Select DisplayName,InstallLocation | Sort-Object Displayname -Descending
Get-ChildItem HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | % { Get-ItemProperty $_.PsPath } | Select DisplayName,InstallLocation | Sort-Object Displayname -Descending
These show different programs and their locations

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 out put from AD or txt

I am trying to run this programme against a a list of remote pc/servers either by AD out TXT and display them in either csv or html if any one can offer some help or advise I would be greatly appreciative.
My only limitation is all my machines run powershell v2 only
Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate |
Format-Table –AutoSize
You want to take the output of that command and put it in a file? PowerShell has a lot of tools to do this. However, you need to remove the Format-Table command first.
See, Format-Table is all about making your command output look really good in a PowerShell window, so it's got a lot of hard returns and columns and things defined in it which make sense to the console, but look like garbage when you export it.
For data like this, I think Comma Separated Value is probably the way to go.
Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* |
Select-Object DisplayName, DisplayVersion, Publisher, InstallDate |
Export-CSV -NoTypeInfo -Path \\server\share\$($env:ComputerName)_Programs.csv
This example will export a CSV, omitting the import-helper info PowerShell normally adds, using the -NoTypeInformation switch. I figured it'd be useful to know the name of the computer which made the file, so that's just what it will do. Edit -Path to point to a server with a share and away you go. You'll end up with files like this:
ComputerA_Programs.Csv
ComputerB_Programs.Csv
ComputerC_Programs.Csv
If you want to pull from all Ad computers
ForEach ($COMPUTER in (Get-ADComputer -Filter * | Select-Object -ExpandProperty Name))
{if(!(Test-Connection -Cn $computer -BufferSize 16 -Count 1 -ea 0 -quiet))
{write-host "cannot reach $computer" -f red}
else{Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate |
Export-CSV -NoTypeInfo -Path "\\server\share$\$Computer_Programs.csv" -NoTypeInformation}}
for if you have list of computers in text
Foreach ($computer in ($computers= Get-Content "c:\Computers.txt" ))
{if(!(Test-Connection -cn $computer -BufferSize 16 -Count 1 -ea 0 -quiet))
{write-host "cannot reach $computer" -f red}
else{
Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate |
Export-CSV -NoTypeInfo -Path "\\server\share$\$Computer_Programs.csv" -NoTypeInformation
}}

How to remove extra lines from Get-WMIObject output powershell

I am running the following query to get the video driver version number
Get-WmiObject Win32_videoController | where {$_.Name -like "Nvidia*"} | Format-table -HideTableHeaders DriverVersion
It returns the data I want plus about 4 extra lines. One before the output and 3 after. It doesn't look like it's going to show up properly in the post.
PS F:\>
Get-WmiObject Win32_videoController | where {$_.Name -like "Nvidia*"} | Format-table -HideTableHeaders DriverVersion
9.18.13.3250
PS F:\>
If you want to determine the driver version, forget about Format-Table. Simply do this:
Get-WmiObject Win32_VideoController -Filter "Name LIKE 'Nvidia%'" |
Select-Object -Expand DriverVersion
Note: You can also use the aliases gwmi for Get-WmiObject and select for Select-Object. Beware, though, that aliases may not be present during script execution depending on your environment. They're basically a means to reduce the amount of typing required in an interactive console.
Not sure exactly if this is what you want but give this a try.
This will only display the "Unique" driver versions. This will get rid of the dupe entrys
Get-WmiObject Win32_videoController | Where {$_.Name -like "Nvidia*"} | Select-Object DriverVersion -Unique | Format-Table -HideTableHeaders