Using regedit to view and set the PowerShell execution policy remotely

If you're looking to find out how Windows determines the execution for PowerShell the following maybe helpful.



Regardless of the version of PowerShell the following registry key is used.

HKLM\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell
ExecutionPolicy REG_SZ

This can be set to one of the following values and you can set this value remotely using regedit.

  • Restricted
  • AllSigned
  • RemoteSigned
  • Unrestricted       
  • Bypass
  • Undefined


However if Group Policy (either through the local Group Policy editor or using Active Directory) is  used the following setting override this.

HKLM\SOFTWARE\Policies\Microsoft\Windows\PowerShell
ExecutionPolicy REG_SZ


It makes sense where possible to use the Group Policy template to modify the PowerShell execution settings



There are a couple of caveats to take into account when reading the setting remotely

  • If the Group Policy key exists and is set to a valid value then this is used
  • If the Group Policy key exists but is set to an invalid value then Restricted is used (the local machine setting is ignored).
  • If the Group Policy key exists but the value is empty the Group Policy setting is ignored and the local setting used.
  • If the registry key does not exist or is set to an unknown value then Restricted is used.


If this sounds a bit tiresome why not check out the latest version of our Windows and Network Audit Tool, XIA Configuration Server which will do all of the detection for you.



Comments

  1. Why not follow us on Twitter? @centrelsolution
    https://twitter.com/centrelsolution

    ReplyDelete

Post a Comment

Popular posts from this blog

Windows Server 2016, 2019, 2022, Windows 10 and Windows 11: Date and time "Some settings are managed by your organization".

TFTPD32 or TFTPD64 reports Bind error 10013 An attempt was made to access a socket in a way forbidden by its access permissions.

Windows Server 2019 desktop icons such as My Computer, Windows cannot access the specified device, path, or file.