I am doing something like this I am running an external powershell script called myfile.ps1 and capturing its output
$a = (& "C:\\mfile.ps1" -arg &q