Registry

PROVIDER NAME
    Registry

DRIVES
    HKLM:, HKCU:

SYNOPSIS
    Provides access to the system Registry keys and values from Windows PowerShell.

DESCRIPTION
    The Windows PowerShell Registry provider lets you get, add, change, clear, and delete Registry keys and values in Windows PowerShell.

    Registry keys are represented as instances of the Microsoft.Win32.RegistryKey class. Registry values are represented as instances of the PSCustomObject class.

    The Registry provider lets you access a hierarchical namespace that consists of Registry keys and subkeys. Registry values and data are not components of that hierarchy. Instead, they are properties of each of the keys.

    The Registry provider supports all the cmdlets that contain the Item noun (the Item cmdlets), such as Get-Item, Copy-Item, and Rename Item. Use the Item cmdlets when you work with Registry keys and subkeys. The Registry provider also supports the cmdlets that contain the ItemProperty noun (the ItemProperty cmdlets). Use the ItemProperty cmdlets when you work with Registry values and data. You cannot use the cmdlets that contain the Content noun (the Content cmdlets) with the Registry provider.

    Each Registry key is protected by a security descriptor. You can use Get-Acl to view the security descriptor of a key.

CAPABILITIES
    ShouldProcess

TASKS
    TASK: Navigating the Registry

        ————————– EXAMPLE 1 ————————–

        This command sets the current location to the HKEY_LOCAL_MACHINE\Software Registry key:

        Set-Location hklm:\software

        ————————– EXAMPLE 2 ————————–

        This command displays the current location:

        Get-Location

    TASK: Managing Registry Keys

        ————————– EXAMPLE 1 ————————–

        This command displays information about each immediate subkey of the HKEY_LOCAL_MACHINE\Software Registry key:

        Get-ChildItem -path hklm:\software

        ————————– EXAMPLE 2 ————————–

        This command creates the TestNew subkey under the HKCU:\Environment subkey:

        New-Item -path hkcu:\Environment\TestNew

        ————————– EXAMPLE 3 ————————–

        This command removes the TestNew subkey of the HKEY_CURRENT_USER\Environment key:

        Remove-Item -path hkcu:\Environment\TestNew

        ————————– EXAMPLE 4 ————————–

        This command copies the TestNew key to the TestCopy subkey:

        Copy-Item -path hkcu:\Environment\TestNew hkcu:\Environment\TestNew\TestCopy

        ————————– EXAMPLE 5 ————————–

        This command displays information about all the subkeys of the HKEY_LOCAL_MACHINE\Software Registry key:

        Get-ChildItem -path hklm:\Software -recurse

        ————————– EXAMPLE 6 ————————–

        This command moves the HKEY_CURRENT_USER\Environment\testnewcopy Registry key, its properties, and all its subkeys and their properties to HKEY_CURRENT_USER\Environment\testnew:

        Move-Item -path hkcu:\environment\testnewcopy `
        -destination hkcu:\environment\testnew

        ————————– EXAMPLE 7 ————————–

        This command renames the HKEY_CURRENT_USER\Environment\testnew Registry key to HKEY_CURRENT_USER\Environment\test:

        Rename-Item -path hkcu:\environment\testnew\ -newname test

        ————————– EXAMPLE 8 ————————–

        This command displays the security descriptor for the specified Registry item:

        Get-Acl -path hkcu:\environment\testnew | Format-List -property *

    TASK: Managing Registry Entries

        ————————– EXAMPLE 1 ————————–

        This command displays the value name and value data for each Registry entry in the HKEY_CURRENT_USER\Environment Registry key:

        Get-Itemproperty -path hkcu:\Environment

        The Default Registry entry is returned only if it has a value.
        ————————– EXAMPLE 2 ————————–

        This command displays the value name and value data for the Temp Registry entry in the HKEY_CURRENT_USER\Environment Registry key:

        Get-Itemproperty -path hkcu:\Environment -name Temp

        ————————– EXAMPLE 3 ————————–

        This command creates the pstest Registry entry in the HKEY_CURRENT_USER key and sets its value to pstestvalue:

        New-Itemproperty -path hkcu:\environment -name “pstest” -value “pstestvalue”

        ————————– EXAMPLE 4 ————————–

        This command updates the value of the pstest Registry entry to updatedvalue in the HKEY_CURRENT_USER\Environment key:

        Set-Itemproperty -path hkcu:\environment -name pstest
        -value “updatedvalue”

        ————————– EXAMPLE 5 ————————–

        This command renames the value name of the pstest Registry entry to pstestnew in the HKEY_CURRENT_USER\Environment key:

        Rename-Itemproperty -path hkcu:\environment -name pstest `
        -newname pstestnew

        ————————– EXAMPLE 6 ————————–

        This command copies the pstestnew Registry entry from the HKEY_CURRENT_USER\Environment key to the HKEY_CURRENT_USER\Environment\testnewcopy key:

        Copy-Itemproperty -path hkcu:\environment `
        -destination hkcu:\environment\testnewcopy -name pstestnew

        ————————– EXAMPLE 7 ————————–

        The command moves the pstestnew Registry entry from the HKEY_CURRENT_USER\environment\testnewcopy key to the HKEY_CURRENT_USER\environment\testnew key:

        Move-Itemproperty -path hkcu:\environment\testnewcopy ‘
        -destination hkcu:\environment\testnew -name pstestnew

        ————————– EXAMPLE 8 ————————–

        This command clears the value of the pstestnew Registry entry in the HKEY_CURRENT_USER\Environment\testnew key:

        Clear-Itemproperty -path hkcu:\environment\testnew -name pstestnew

        You can use the Clear-Item cmdlet to clear the value of the default Registry entry for a subkey. For example, the following command clears the value of the default entry of the HKEY_CURRENT_USER\Environment\testnew Registry key:

        Clear-Item -path hkcu:\environment\testnew
        ————————– EXAMPLE 9 ————————–

        This command removes the pstestnew Registry entry from the HKEY_CURRENT_USER\Environment\testnew Registry key:

        Remove-Itemproperty -path hkcu:\environment\testnew `
        -name pstestnew

        ————————– EXAMPLE 10 ————————–

        This command updates the value of the default Registry entry in the HKEY_CURRENT_USER\Environment\testnew key to “default value”:

        Set-Itemproperty -path hkcu:\environment\testnew `
        -name “(default)” -value “default value”

        You can also update the default value of a Registry key by using the Set-Item cmdlet. For example, the following command updates the default value of the testnew key:

        Set-Item -path hkcu:\environment\testnew -value “another default value”

DYNAMIC PARAMETERS
    -Type <Microsoft.Win32.RegistryValueKind>
        Specifies the data types to use when storing values in the Registry, or identifies the data type of a value in the Registry.

            String
                Specifies a null-terminated string. Equivalent to REG_SZ.

            ExpandString
                Specifies a null-terminated string that contains unexpanded references to Environment Variables that are expanded when the value is retrieved. Equivalent to REG_EXPAND_SZ.

            Binary
                Specifies binary data in any form. Equivalent to REG_BINARY.

            DWord
                Specifies a 32-bit binary number. Equivalent to REG_DWORD.

            MultiString
                Specifies an array of null-terminated strings terminated by two null characters. Equivalent to REG_MULTI_SZ.

            QWord
                Specifies a 64-bit binary number. Equivalent to REG_QWORD.

            Unknown
                Indicates an unsupported Registry data type, such as REG_RESOURCE_LIST.

        Cmdlets Supported: Set-Item

NOTES

RELATED LINKS
    about_providers