Reputation: 135
I am currently trying to use the Get-RemoteProgram
script to list of installed programs on remote computers.
Not only do I want to capture the remote program list but also the version which is straight forward for a single system.
RemoteProgram -ComputerName remotecomputername -Property DisplayVersion,VersionMajor
ProgramName ComputerName DisplayVersion VersionMajor ----------- ------------ -------------- ------------ System Center Endpoint Protection remotecomputername 4.7.214.0 4 Microsoft Visual Studio 2010 Tools for Office Runtime (x64) remotecomputername 10.0.50903 4 Synaptics Pointing Device Driver remotecomputername 18.0.7.34 18
However, when I loop this across multiple systems I lose the DisplayVersion
and MajorVersion
fields completely.
Get-Content -Path C:\Temp\computerlist.txt | ForEach-Object -Begin {RemoteProgram} -Process {RemoteProgram -ComputerName $_ -Property DisplayVersion,VersionMajor}
ProgramName ComputerName ----------- ------------ System Center Endpoint Protection remotecomputer Microsoft Visual J# 2.0 Redistributable Package - SE (x64) remotecomputer Mozilla Firefox 57.0.2 (x64 en-US) remotecomputer Mozilla Maintenance Service remotecomputer
Upvotes: 0
Views: 381
Reputation: 47862
This is a case of PowerShell's output formatting.
When an object is returned, you get the full object and all of its properties.
When you try to display an object without instructions, PowerShell does its best to display it appropriately. That means it will decide which properties to show, whether to display them as a table or list, etc.
You can override how its displayed with Format-*
commands, but for the purposes of using the objects, all the information is there.
That means if you pipe it to something like Export-Csv
, it will use all the properties even if you aren't seeing them in a normal display.
If you want to see them specifically, use a Format-*
command, but again those are for display only; don't send the out of those to other commands.
Upvotes: 2