I am running a PowerShell script using System.Management.Automation in VB.NET, and the script runs fine.
I am then pulling the results from the script using the command below and I can see the results in my variable sResults when looking at it in the debugger.
Dim sResults = ps.Runspace.SessionStateProxy.GetVariable("results")
And I can loop through each item in SResults using
For Each sResult In sResults
But I can’t work out how to actually obtain any of the values stored in this variable within my code, I have tried using TryCast to convert it to a PSObject, but still at a loss.
As you can see in the screenshot below all the information I want is there, I just need to know how to get it out, namely the value of Exception and PSComputerName (or) TargetObject initially.
Any help would be much appreciated, spent hours search forums and googling etc but can’t seem to find much reference to GetVariable or similar issues.
