Powershell window wont stay open for start-process enter-pssession in new window

Viewed 26

I have this command that works but the window wont stay open. I need this to open in a new window and not in the initial window. Is there anyway to get this to not close after it establishes a PS Session?

start-process powershell.exe -ArgumentList { Enter-PSSession -ComputerName my_computer -Credential USER -SessionOption (New-PSSessionOption -NoMachineProfile)}
1 Answers

Looks like powershell.exe needed the -noexit option. It wasn't working even without start-process. Notice you have to quote it or else it looks like a start-process parameter.

start-process powershell.exe -ArgumentList '-noexit',{ Enter-PSSession -ComputerName my_computer -Credential USER -SessionOption (New-PSSessionOption -NoMachineProfile)}
Related