powershellpowershell-5.1powershell-7.0

Start Powershell 5 out of Powershell 7


My main Script is Powershell 7, but i want to run a function in powershell 5 (because this function is only possible in powershell 5).

I also want to give the function a psobject and return a psobject, can anyone help me?

I tried to start it my Start-Process but it doesn't start correctly.


Solution

  • It's simply

    $result = powershell.exe -file $ScriptPath $ParameterObject