How to let PowerShell x86 return an object while call powershell x86 cmdlet from powershell x64

Ask your Windows PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
ivan.liao@live.com
Posts: 13
Meble kuchenne na zamówienie - na wymiar - Wrocław
Joined: Sat Mar 09, 2019 4:47 am

How to let PowerShell x86 return an object while call powershell x86 cmdlet from powershell x64

Post by ivan.liao@live.com »

Hi everyone here,

I'm currently developing a tools with PowerShell. I would like to let this tools run in PowerShell x64. But some of my action need to call a CmdLet in a DLL, but this dll does not has x64 version. I have to use PowerShell x86 to get this done and get the result. Something like this:

C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -command "& { Import $dll; Do-Someting }"
However, this method to call a dll returns result as string. How can I let it return the original object from CmdLet Do-Someting?

Thanks in advance!

jvierra
Posts: 14213
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: How to let PowerShell x86 return an object while call powershell x86 cmdlet from powershell x64

Post by jvierra »

You cannot return objects from external programs. You can only return strings. YOU could output XML and turn that into an object.

Get-Service spooler | convertto-xml

Locked