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

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
PowerShell
PowerShell
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
    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.