PyWinrm Persistent PowerShell Sessions
You should use pypsrp, which uses PowerShell remoting natively.
The examples in the GitHub repo will show you how, and you can continually use .add_script()
or add_cmdlet()
to make multiple calls within your session.
WinRM (and by extension pywinrm
) is not strictly related to PowerShell, so that call you're doing likely just opens powershell.exe
with whatever you send it.
PSRP is a separate protocol, which runs over WinRM as its transport, so you'll be connecting to a hosted PowerShell session.