Skip to content

Fix group policy cache #2877

Closed
Closed

Description

The internal Group Policy cache does not use a unique key and ends up returning MachinePolicy ExecutionPolicy for a UserPolicy query.

Update the cache code to use a fully unique key.

Investigate using a Tuple instead of concatenated string for the cache key to improve performance.

Steps to reproduce

Set Group Policy UserPolicy, ExecutionPolicy to RemoteSigned
Start new PowerShell session
Run 'Get-ExecutionPolicy -List'

Expected behavior

ExecutionPolicy UserPolicy set to RemoteSigned

Actual behavior

ExecutionPolicy UserPolicy set to Undefined

Activity

  1. iSazonov commented on Jan 20, 2018

    @iSazonov
    Collaborator

    /cc Dongbo Wang (@daxian-dbw) It seems you already improved the code.

  2. daxian-dbw commented on Jan 22, 2018

    @daxian-dbw
    Member

    I verified the reproduce steps on PSCore 6.0.0 and the issue seems to be fixed:

    PS:4> Get-Item HKCU:\Software\Policies\Microsoft\PowerShellCore
    
        Hive: HKEY_CURRENT_USER\Software\Policies\Microsoft
    
    Name                           Property
    ----                           --------
    PowerShellCore                 EnableScripts   : 1
                                   ExecutionPolicy : RemoteSigned
    
    PS:5> Get-ExecutionPolicy -List
    
            Scope ExecutionPolicy
            ----- ---------------
    MachinePolicy       Undefined
       UserPolicy    RemoteSigned
          Process       Undefined
      CurrentUser       Undefined
     LocalMachine    RemoteSigned
    

    Given that, I'm closing this issue. Paul Higinbotham (@PaulHigin) Feel free to re-open this issue if you think it's not fixed.

  3. PaulHigin commented on Jan 22, 2018

    @PaulHigin
    ContributorAuthor

    Dongbo Wang (@daxian-dbw) Why do we assume this is fixed? Please provide a link to the PR that fixed it.

  4. daxian-dbw commented on Jan 22, 2018

    @daxian-dbw
    Member

    Here is the PR: #5791 The group policy cache was redesigned in that PR.

  5. PaulHigin commented on Jan 22, 2018

    @PaulHigin
    ContributorAuthor

    Thanks. Agreed that this is no longer an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Resolution-FixedThe issue is fixed.WG-Enginecore PowerShell engine, interpreter, and runtime

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions