r/PowerShell • u/LordLoss01 • Mar 15 '26
Powershell script that acts as powershell when called?
Yeah, I know the title is confusing. I have a system where I can only run PowerShell scripts. I cannot run individual commands themselves, only scripts. It is an actual terminal.
However, it allows you to run it with a parameter. I've kind of managed to get working by doing the below:
param(
[Parameter(Mandatory = $true)]
[string]$Command
)
Powershell.exe "$Command"So I would do run PowerShellScript.ps1 -parameters Get-Process. This works.
Problem is, as soon as there's a space in the parameter, it fails, thinking it's a separate parameter. So I can't do run PowerShellScript.ps1 -parameters Get-process | where processname -like "*Teams*". Any advice on how to get around this? The terminal I have is very basic, trust me when I tell you it can't do much. The solution has to lie within the script itself.
View all comments
Show parent comment
2
u/PS_Alex Mar 16 '26
Not familiar with Defender Live Response myself, but reviewing Investigate entities on devices using live response in Microsoft Defender for Endpoint - Microsoft Defender for Endpoint | Microsoft Learn to understand how it works, I highly suspect that a Live Response session does not create a real remote Powershell session. Instead, it probably works similarly to a REST API (send a command, wait for result of that command).
The part about cancelling a command saying that CTRL+C only causes ignoring the response on the portal-side, but command would continue running on the agent-side, is what lead me to that conclusion.