Skip to content

Registry changes not persisted to registry when using PowerShell installed from Windows Store #14407

@cdhgee

Description

@cdhgee

Steps to reproduce

THIS ISSUE IS SPECIFIC TO POWERSHELL INSTALLED FROM THE WINDOWS STORE - THE MSI VERSION BEHAVES CORRECTLY

Example 1: create a registry entry using PowerShell and see if it can be accessed outside PowerShell

Create a new registry entry using New-ItemProperty

❯ New-ItemProperty -Path HKCU:\TESTKEY\ -Name Test1 -PropertyType Dword -Value 1

Test1        : 1
PSPath       : Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_USER\TESTKEY\
PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_USER
PSChildName  : TESTKEY
PSDrive      : HKCU
PSProvider   : Microsoft.PowerShell.Core\Registry

Using reg query does not show this entry in the registry:

❯ reg query HKCU\TESTKEY

Example 2: update an existing registry entry using PowerShell

Display the existing registry entry:

❯ reg query HKCU\TESTKEY

HKEY_CURRENT_USER\TESTKEY
    Test2    REG_DWORD    0x1

Update the registry entry using Set-ItemProperty:

❯ Set-ItemProperty HKCU:\TESTKEY\ -Name Test2 -Value 5

Observe that reg query and Get-ItemProperty now display different values.

❯ reg query HKCU\TESTKEY

HKEY_CURRENT_USER\TESTKEY
    Test2    REG_DWORD    0x1

❯ Get-ItemProperty -Path HKCU:\TESTKEY\

Test2        : 5
PSPath       : Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_USER\TESTKEY\
PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_USER
PSChildName  : TESTKEY
PSDrive      : HKCU
PSProvider   : Microsoft.PowerShell.Core\Registry

Example 3: delete an existing registry entry using PowerShell

Display the existing registry entry:

❯ reg query HKCU\TESTKEY

HKEY_CURRENT_USER\TESTKEY
    Test3    REG_DWORD    0x4

❯ Get-ItemProperty HKCU:\TESTKEY\

Test3        : 4
PSPath       : Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_USER\TESTKEY\
PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_USER
PSChildName  : TESTKEY
PSDrive      : HKCU
PSProvider   : Microsoft.PowerShell.Core\Registry

Delete the entry using Remove-ItemProperty:

❯ Remove-ItemProperty -Path HKCU:\TESTKEY\ -Name Test3

Observe that reg query still shows the entry but Get-ItemProperty does not:

❯ reg query HKCU\TESTKEY\

HKEY_CURRENT_USER\TESTKEY
    Test3    REG_DWORD    0x4

❯ Get-ItemProperty HKCU:\TESTKEY\

Expected behavior

Creating/editing/deleting registry entries should produce identical effects regardless of the tool used.

  • Registry entries created using New-ItemProperty should be visible outside PowerShell
  • Updates to registry entries made using Set-ItemProperty should be visible outside PowerShell
  • Registry entries deleted using Remove-ItemProperty should not be visible after deletion

Actual behavior

When using PowerShell installed from the Windows Store:

  • Registry entries created using New-ItemProperty are not visible outside PowerShell
  • Changes made to registry entries using Update-ItemProperty are not visible outside PowerShell
  • Registry entries deleted using Remove-ItemProperty are still visible outside PowerShell

When using the PowerShell installed via MSI, the actual behavior is correct.

Environment data

Name                           Value
----                           -----
PSVersion                      7.1.0
PSEdition                      Core
GitCommitId                    7.1.0
OS                             Microsoft Windows 10.0.19042
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-FixedThe issue is fixed.WG-Maintainers-Buildspecific to affecting the build

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions