Set PowerShell language mode to Constrained Language mode for all user using Intune

LonLee 11 Reputation points


Is there a way to set Constraint Language mode as default on Powershell for all user laptops? I'm trying to find a way to do it through Intune but not able to find any policy for this restriction.

Thanks & best regards,

Lon Lee

Microsoft Intune
Microsoft Intune
A Microsoft cloud-based management solution that offers mobile device management, mobile application management, and PC management capabilities.
4,585 questions
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,229 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Crystal-MSFT 45,011 Reputation points Microsoft Vendor

    @LonLee, Thanks for the reply. Based on my researching, I find we can set environment variable "__PSLockdownPolicy" to 4 to set the PowerShell language mode to Constrained Language mode

    Note: Non-Microsoft link, just for the reference.

    To do this in bulk, we can save the following command in PowerShell script. And run it on the device to see if it works.

    reg add "HKLM\System\CurrentControlSet\Control\Session Manager\Environment" /v "__PSLockDownPolicy" /t reg_SZ /d "4" /f

    After the above PowerShell Script test successfully, then we can deploy it via Intune:

    Hope the above information can help.

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.