I am new to Powershell and I am having trouble with the following. I need to run a Get-WmiObject command and get programs and versions. Here is the code:
Get-WmiObject -Class Win32_Product | where Name -eq "Microsoft Policy Platform" | select Name, Version >> c:\Temp\PRograms.txt ;
Get-WmiObject -Class Win32_Product | where Name -eq "Mitel Connect" | select Name, Version >> c:\Temp\PRograms.txt
I get this output:
Name Version
---- -------
Microsoft Policy Platform 68.1.1010.0
Name Version
---- -------
Mitel Connect 214.100.1252.0
What I am hoping to get is:
Name Version
---- -------
Microsoft Policy Platform 68.1.1010.0
Mitel Connect 214.100.1252.0
I have tried making it 1 line, separate commands, google and looking at like scripts with no luck. I am hoping someone can point me in the right direction so I can build on it.
Get-WmiObject -Class Win32_Product | where Name -in @( “Microsoft Policy Platform", “Mitel Connect") | select Name, Version >> c:\Temp\PRograms.txt ;Get-CimInstance) superseded the WMI cmdlets (e.g.,Get-WmiObject) in PowerShell v3 (released in September 2012). Therefore, the WMI cmdlets should be avoided, not least because PowerShell (Core) v6+, where all future effort will go, doesn't even have them anymore. Note that WMI still underlies the CIM cmdlets, however. For more information, see this answer.