You have written your PS script using the MIM WAL. You are returning a single value to the WorkflowData library. Here is the error you get when you run it
The PowerShell script returned a collection of values with inconsistent types
You check your variables, you declare the types, yet you still get the error
When you use the return attribute in PS it returns all output that is written to the screen. You may have a command that creates a new object such as New-mailbox or Enable-mailbox. Such a command will output the result to the screen and that will be piped into your return output.
Use a variable to capture the output of all your commands e.g
$d = Import-PSsession $g –allowclobber