3

I have the following powershell script which loads a custom .NET DLL this contains the ScriptResult class, it is intern executed from a VB.NET app.

Add-Type -Path $myLibPath

$result = New-Object TheLibrary.ScriptResult

In the VB.NET app I want to get the result object but the following doesnt seem to work

'get the script result
Dim result As ScriptResult = run.SessionStateProxy.GetVariable("result")

What am I not doing correctly?

2 Answers 2

2

a) define the variable to the runtime first with

run.SessionStateProxy.SetVariable("result", null)

b) maybe could help to mark $result as global (not verified):

$global:result = New-Object TheLibrary.ScriptResult

Sign up to request clarification or add additional context in comments.

1 Comment

After a painful search I was able to success with your second option. Thanks a lot.
1

GetVariable returns a PSVariable instance. The variable's value is in the .Value property. You'll probably need to cast it (DirectCast) to your ScriptResult type as Value returns an Object.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.