Powershell Start-Process to start Powershell session and pass local variables

Question:

Is there a way to use the Powershell Start-Process cmdlet to start a new Powershell session and pass a scriptblock with local variables (once of which will be an array)?

Example:

Thanks.

Answer:

I was able to get this to work by joining the array with “/” to create a string and entering the scriptblock into another .ps1 script with appropriate parameters and splitting the joined string back to an array within the second script and using

Ugly, but it’s the only way I could get it to work. Thanks for all the replies.

Source:

Powershell Start-Process to start Powershell session and pass local variables by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply