GroupPolicyObject.GetRegistrySettings Method (RegistryHive, String)


Retrieves the registry-based policy settings for a registry key and all its values from the Group Policy object (GPO).

Namespace:   Microsoft.GroupPolicy
Assembly:  Microsoft.GroupPolicy.Management.Interop (in Microsoft.GroupPolicy.Management.Interop.dll)


public ReadOnlyCollection<RegistryItem> GetRegistrySettings(
    RegistryHive hive,
    string keyPath
ReadOnlyCollection<RegistryItem^>^ GetRegistrySettings(
    RegistryHive hive,
    String^ keyPath
member GetRegistrySettings : 
        hive:RegistryHive *
        keyPath:string -> ReadOnlyCollection<RegistryItem>
Public Function GetRegistrySettings (
    hive As RegistryHive,
    keyPath As String
) As ReadOnlyCollection(Of RegistryItem)


  • hive
    Type: Microsoft.Win32.RegistryHive

    One of the RegistryHive values that specifies the registry hive for which to retrieve the registry-based policy settings. Specify CurrentUser to retrieve policy settings from User Configuration. Specify LocalMachine to retrieve policy settings from Computer Configuration. No other values are supported.

  • keyPath
    Type: System.String

    The path to the registry key for which to retrieve the registry-based policy settings.

Return Value

Type: System.Collections.ObjectModel.ReadOnlyCollection<RegistryItem>

Returns ReadOnlyCollection<T>. A read-only collection of PolicyRegistrySetting objects, each of which represents a registry-based policy setting.


Exception Condition

keyPath is an empty string (“”).

- or -

No registry-based policy settings exist for the specified registry key or its values.


keyPath is null.


hive is not a supported RegistryHive value.


The GroupPolicyObject is disposed.


The registry key for which to retrieve registry-based policy settings is specified by a combination of the hive and the keyPath parameters. The method retrieves all registry-based policy settings for the key and its first-level values.

See Also

GroupPolicyObject Class
Microsoft.GroupPolicy Namespace

Return to top