Get-ItemPropertyValue returns the two registry values as separate strings, so Invoke-Command outputs them as separate objects. Try having the remote script block construct a single object containing the values you want and include the server name. Then PowerShell can format those objects as a normal table.
$Servers = Import-Csv "C:\path\servers.csv"
$Results = foreach ($Server in $Servers) {
Invoke-Command -ComputerName $Server.ServerName -ScriptBlock {
$RegPath = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{7DC36D55-4510-4307-9550-57A83DC6A1C2}'
$App = Get-ItemProperty -LiteralPath $RegPath
[PSCustomObject]@{
ServerName = $env:COMPUTERNAME
AgentName = $App.DisplayName
Version = $App.DisplayVersion
}
}
}
$Results | Format-Table -AutoSize
That should produce:
ServerName AgentName Version
--------------------------------
MyServer1 Rubrik Backup Service 9.4.3
MyServer2 Rubrik Backup Service 9.4.3
MyServer3 Rubrik Backup Service 9.4.3
The remote script block returns one PSCustomObject per server rather than returning DisplayName and DisplayVersion as two independent output values. Also, if your CSV column is not actually named ServerName, replace $Server.ServerName with the actual column name.
If the above response helps answer your question, remember to "Accept Answer" so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.
hth
Marcin