I want to be able to look for an installed program in powershell and output to a file the results. So far, I have something that will list the install programs, and select the string that has the name of the program, but I am not sure how to specify a text file for it to use for the list of systems, and a way to make it output cleanly.
Get-WmiObject -Class Win32_Product -cn $computernamehere | Select-Object -Property Name | Sort-Object Name | Select-String Vmware | Out-File C:\Users\ajstepanik\Desktop\installed_programs.txt
I would like it to output in a fashion like:
COMPUTER1 - VMware Horizon View Client
COMPUTER2 - VMware Horizon View Client
COMPUTER3 - VMware Horizon View Client
Currently it outputs:
@{Name=VMware Horizon View Client}
@{Name=VMware Horizon View Client}
@{Name=VMware Horizon View Client}
In your case I recant my previous statement about
-ExpandProperty
. I am still right in that it will return just a string array instead of the object property. However I think that you will have more options if you leave it as an object and just add the property "Computer" which you are looking for. That was we can just have it as a nice CSV! I am going to assume there is some loop structure here that you have not shown.Changed the
select-string
to aWhere
nMatch
since i kept the object. UsedAdd-Member
to add a property forComputer
. Now we can useExport-CSV
Forgot about
foreach($x in $y)
doesnt work with output the way the other foreach does.