Script works in Poweshell, but not PS Studio.

Hello, I have a script that looks at an OU and finds Symantec Version based on the Reg Value and gives me a reporting of ones that match. What do I need to do to get it working in a GUI?

https://pastebin.com/TtL6RJwq

I have tried piping to Out-String and then trying to display results to RichTextBox with no results being displayed.

TIA

You code is just about iterating through a list of servers and getting the reg key values using remoting. Code looks fine , can you show us how your are putting this in a RichTextBox ?
And you no need to iterate on each servers, -ComputerName parameter of Invoke-Command
takes array of computers do the filtering inside the scriptblock as well. Hence ,

Invoke-Command -ComputerName $Servers.Name -ScriptBlock {
Get-ItemProperty "HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{C9BC5C47-40AC-4342-BE80-1BC2B4AADFC3}"} | where-Object -FilterScript  {$_.DisplayVersion -notmatch "12.1.7445.7000" } | select PSComputerName,DisplayVersion
 

I’m actually using a modified GUI, so I was putting:

“$results = Invoke…” | Out-String

Add-RichTextBox $results

I’m sure that’s completely wrong.

“$results = Invoke…” is the problem here, anything between quotes are treated as string.
You can capture the output in a variable and use the variable further, for example,

$Results = Invoke-Command -ComputerName $servers -Scriptblock { # your code }
$TextBox.Text = $Results | Out-String

Hello.

This is driving me nuts.

How do I get this to display to a richtextbox?

Foreach ($server in $servers)

{

Invoke-command -ComputerName $Server.Name -ScriptBlock {Get-ItemProperty “…”} | Select PSComputerName, DisplayVersion | where {$_.DisplayName -Match “Software” } | Out-String

}