- Access exclusive content
- Connect with peers
- Share your expertise
- Find support resources
03-12-2025 06:21 AM
Hello,
I was wondering if there may be a possibility to block specific power shell commands and how would this be done? For instance, we would like to block this command:
Add-LocalGroupMember -Group "Administrators" -Member "username" ?
03-12-2025 08:45 AM
iI was wondering if there may be a possibility to block specific power shell commands and how would this be done? For instance, we would like to block this command in cyberark epm - Add-LocalGroupMember -Group "Administrators" -Member "username" ?
Yes, you can block specific PowerShell commands like
Add-LocalGroupMember
using CyberArk Endpoint Privilege Manager (EPM). This is particularly useful for preventing users from adding themselves or others to the Administrators group.
Here's how you can implement this:
This approach aligns with CyberArk's security best practices for protecting against LOLBAS (Living Off The Land Binaries And Scripts) attacks, as described in the Secure endpoints with EPM policies documentation.
For additional protection, you might also want to consider:
This multi-layered approach will provide comprehensive protection against unauthorized privilege escalation attempts.
03-12-2025 08:45 AM
iI was wondering if there may be a possibility to block specific power shell commands and how would this be done? For instance, we would like to block this command in cyberark epm - Add-LocalGroupMember -Group "Administrators" -Member "username" ?
Yes, you can block specific PowerShell commands like
Add-LocalGroupMember
using CyberArk Endpoint Privilege Manager (EPM). This is particularly useful for preventing users from adding themselves or others to the Administrators group.
Here's how you can implement this:
This approach aligns with CyberArk's security best practices for protecting against LOLBAS (Living Off The Land Binaries And Scripts) attacks, as described in the Secure endpoints with EPM policies documentation.
For additional protection, you might also want to consider:
This multi-layered approach will provide comprehensive protection against unauthorized privilege escalation attempts.
03-12-2025 08:45 AM
iI was wondering if there may be a possibility to block specific power shell commands and how would this be done? For instance, we would like to block this command in cyberark epm - Add-LocalGroupMember -Group "Administrators" -Member "username" ?
Yes, you can block specific PowerShell commands like
Add-LocalGroupMember
using CyberArk Endpoint Privilege Manager (EPM). This is particularly useful for preventing users from adding themselves or others to the Administrators group.
Here's how you can implement this:
This approach aligns with CyberArk's security best practices for protecting against LOLBAS (Living Off The Land Binaries And Scripts) attacks, as described in the Secure endpoints with EPM policies documentation.
For additional protection, you might also want to consider:
This multi-layered approach will provide comprehensive protection against unauthorized privilege escalation attempts.
05-08-2025 05:14 AM
Hello @Touseef-ur rehman ,
We have tried the same approach, but in this case, the command is not being blocked as expected. We are using the following command:
net localgroup "Administrators" /add "AzureAD\username"
We have included the parameter that contains : net localgroup "Administrators"
05-08-2025 08:36 AM
Hmm I do recall might be related, that there is a registry key that needs to amending to do with the LSASS that then allows epm to inject and handle the admin group, maybe this is why users can add themselves to the group via powershell/cmd - fix mentioned here - https://community.cyberark.com/s/question/0D7Ht000008iEluKAE/remove-local-administrators-on-windows-not-working?fromEmail=1&s1oid=00D300000000HNg&s1nid=0DB50000000TRHA&s1uid=005Ht00000Ai0zl&s1ext=0&emkind=chatterBestAnswerNotification&emtm=1722338622637
05-08-2025 08:36 AM
Hmm I do recall might be related, that there is a registry key that needs to amending to do with the LSASS that then allows epm to inject and handle the admin group, maybe this is why users can add themselves to the group via powershell/cmd - fix mentioned here - https://community.cyberark.com/s/question/0D7Ht000008iEluKAE/remove-local-administrators-on-windows-not-working?fromEmail=1&s1oid=00D300000000HNg&s1nid=0DB50000000TRHA&s1uid=005Ht00000Ai0zl&s1ext=0&emkind=chatterBestAnswerNotification&emtm=1722338622637
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!

