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

LonLee 11 Reputation points
2023-09-13T07:24:53.84+00:00

Hi,

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

Windows for business Windows Server User experience PowerShell
Microsoft Security Intune Other
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Crystal-MSFT 53,981 Reputation points Microsoft External Staff
    2023-09-13T08:32:05.53+00:00

    @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

    https://devblogs.microsoft.com/powershell/powershell-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:

    https://learn.microsoft.com/en-us/mem/intune/apps/intune-management-extension

    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.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.