- Access exclusive content
- Connect with peers
- Share your expertise
- Find support resources
10-21-2025 01:11 PM
We have CyberArk EPM SaaS version (25.10.0.5070)
I want to use below regular expression to block few powershell commands that fetch from the internet and pipe straight into Invoke-Expression. We drafted below regex, but when configured in the 'Parameter' property field's value, is not able to detect the sample commands listed. Has anyone experience this issue with using regex?
RegEx:
^.*(iwr|invoke-webrequest)[^|]*\|\s*(iex|invoke-expression).*RegEx explanation:
(iwr|invoke-webrequest) -> matches 'iwr' or 'invoke-webrequest' commands to download from internet
[^|]*\| -> eats everything from the end of iwr up to the first |
\s*(iex|invoke-expression) -> confirms the next token is 'iex' or 'invoke-expression'Sample lines of command the regular expression should be able to catch:
powershell.exe iwr https://google.com | iex
powershell.exe iwr https://google.com | invoke-expression
powershell.exe invoke-webrequest https://google.com | iex
10-22-2025 02:24 AM
CyberArk EPM uses the CAtlRegExp class; therefore, we must use the syntax and features supported by CAtlRegExp
Below simple example match either "iwr" or "invoke-webrequest" match
.*((iwr)|(invoke-webrequest)).*
10-22-2025 07:11 PM
Thank you so much @Manikandan Krishnasamy for this sample regex. I was able to only match the command when there is no pipe (|) used at all in the command. For example this below regex,
.*((iwr)|(invoke-webrequest)).*((http)|(https)).*((iex)|(invoke-expression)).*is able to match this command:
powershell.exe iwr https://google.com iexbut NOT able to match this command because there is a pipe:
powershell.exe iwr https://google.com | iexCould someone from CyberArk EPM support/engineer confirm for sure if this truly a limitation?
Click Accept as Solution to acknowledge that the answer to your question has been provided.
The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!
These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!
The LIVEcommunity thanks you for your participation!

