Remove column name from PowerShell select-object results
<p>Overall my goal is to get the VNC version for a list of remote computers along with the uninstall GUID so I can remotely uninstall VNC Viewer from certain computers.  I have used the Get-WmiObject -Class Win32_Product but that is extremely slow.</p>

<p>I have the following script but in the results it includes the name of the select-object parameter.</p>

<pre><code>$computers = Get-Content -Path "C:\Computers.txt"

$Results = @()

ForEach ($Computer in $Computers) {
    $Results += New-Object PSObject -Property @{
        "ComputerName" = $Computer

        "Name" = Invoke-Command -ComputerName $Computer -ScriptBlock { Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* } `
        | Where-Object -FilterScript {$_.DisplayName -like "VNC V*"} | select-object DisplayName

        "DisplayVersion" = Invoke-Command -ComputerName $Computer -ScriptBlock { Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* } `
        | Where-Object -FilterScript {$_.DisplayName -like "VNC V*"} | select-object DisplayVersion

        "ModifyPath" = Invoke-Command -ComputerName $Computer -ScriptBlock { Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* } `
        | Where-Object -FilterScript {$_.DisplayName -like "VNC V*"} | select-object ModifyPath

        "Vendor" = Invoke-Command -ComputerName $Computer -ScriptBlock { Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* } `
        | Where-Object -FilterScript {$_.DisplayName -like "VNC V*"} | select-object Publisher

    }
}

$Results | Select-Object ComputerName,Name,DisplayVersion,ModifyPath,Vendor | Sort-Object ComputerName  | Export-Csv  C:\VNC.csv -notype ;
</code></pre>

<p>My results look like this:</p>

<p>ComputerName&nbsp;&nbsp; : ComputerName <br>
Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: @{DisplayName=VNC Viewer 5.2.3} <br>
DisplayVersion&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: @{DisplayVersion=5.2.3} <br>
ModifyPath&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: @{ModifyPath=MsiExec.exe /I{18B1E36F-0DA3-4FDA-BC57-DD815B0DF3B2}}<br>
Vendor&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: @{Publisher=RealVNC Ltd}</p>

<p>I would want it to look like this:</p>

<p>ComputerName&nbsp;&nbsp; : ComputerName <br>
Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: VNC Viewer 5.2.3 <br>
DisplayVersion&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: 5.2.3 <br>
ModifyPath&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: MsiExec.exe /I{18B1E36F-0DA3-4FDA-BC57-DD815B0DF3B2}<br>
Vendor&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: RealVNC Ltd</p>

<p>Is this possible or am I going about this script entirely wrong?  I haven't figured out a way to run this Invoke-Command for multiple parameters and still output the results in individual columns any other way.</p>

<p>This script works but takes forever for 100's of computers:</p>

<pre><code>if (Test-Path C:\VNCInstalled.csv) {Remove-Item C:\VNCInstalled.csv}
if (Test-Path C:\Computers.txt) {Remove-Item C:\Computers.txt}
$DirSearcher = New-Object System.DirectoryServices.DirectorySearcher([adsi]'')
$DirSearcher.Filter = '(&amp;(objectClass=Computer)(!(cn=*esx*)) (!(cn=*slng*)) (!(cn=*dcen*)) )'
$DirSearcher.FindAll().GetEnumerator() | sort-object { $_.Properties.name } `
| ForEach-Object { $_.Properties.name }`
| Out-File -FilePath C:\Computers.txt

Get-Content -Path c:\Computers.txt `
| ForEach-Object {Get-WmiObject -Class Win32_Product -ComputerName $_} `
| Where-Object -FilterScript {$_.Name -like "VNC V*"} `
| select-object @{Name="ComputerName";Expression={$_.PSComputerName}},
                Name,
                @{Name="InstallLocation";Expression={$_.PackageCache}},
                Vendor,
                Version,
                @{Name="GUID";Expression={$_.IdentifyingNumber}} `
| Sort-Object ComputerName `
| Export-CSV -path c:\VNCInstalled.csv -notype
</code></pre>