How can I supress Invoke Powershell return value?

Hi guys,

so I have a strange problem.
I’m using a powershell script that does some api calls and stuff.

I use the PowerShellVariables property and put in 2 arguments (these work) and get back one variable which is of type Object[].

But when I run it I always get the error Invoke Power Shell: Unable to cast object of type 'System.Management.Automation.PSCustomObject' to type 'System.Object[]'.

I think this is because powershell returns basically everything you store in a variable and somewhere along the line it returns one of these objects I’m about to add into the array.

Can I supress the script somehow cause I don’t need a response variable or modify the Invoke Powershell activity in some shape or form?

Cause if I just change the TypeArgument to the one stating in the error message, I will get the next error that now it doesn’t fit another variable it gets returned. I want to “disable” this since I dont work with the ouput or the output type just with passed in Variables that gets data into the script and out of the script.

Or am I getting this whole Activity wrong and I have to do it another way?

For example the allUserLogs in my Powershell Script is a variable called $allUserLogs and is an array of objects.

Here is how it looks like:

I’m really stuck here and would love to hear from you guys :slight_smile: thank you.

Hi @GeraltDieSocke

I wonder if you tried Object, you know everything is extended from Object.
If it still doesn’t work, you can provide your PS script for help anyone who can help you reproduce your problem.

1 Like

Thank you that was it. So simple I love it. Thx.

After I get the “object” back I cast it back like this CType(allUserLogs, IEnumerable).Cast(Of Object)().ToArray() now I can loop through it.


This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.