GroupPolicyObject.CreateNew Method (String, String, Boolean, Boolean)

 

Creates a new Group Policy object (GPO) with the specified display name by using the Active Directory path to a domain or a domain controller.

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

Syntax

public void CreateNew(
    string domainOrServerPath,
    string gpoDisplayName,
    bool readOnly,
    bool loadRegistry
)
public:
void CreateNew(
    String^ domainOrServerPath,
    String^ gpoDisplayName,
    bool readOnly,
    bool loadRegistry
)
member CreateNew : 
        domainOrServerPath:string *
        gpoDisplayName:string *
        readOnly:bool *
        loadRegistry:bool -> unit
Public Sub CreateNew (
    domainOrServerPath As String,
    gpoDisplayName As String,
    readOnly As Boolean,
    loadRegistry As Boolean
)

Parameters

  • domainOrServerPath
    Type: System.String

    The Active Directory path of the domain or the domain controller in which to create the GPO. If a domain controller is specified, the GPO is created on that domain controller. If a domain is specified, the system selects a domain controller on the caller's behalf.

  • gpoDisplayName
    Type: System.String

    The display name for the new GPO.

  • readOnly
    Type: System.Boolean

    true to open the GPO in read-only mode; otherwise, false.

  • loadRegistry
    Type: System.Boolean

    true to load the registry; otherwise, false.

Exceptions

Exception Condition
ArgumentException

The domainOrServerPath parameter or the gpoDisplayName parameter is an empty string (“”).

ArgumentNullException

The domainOrServerPath parameter or the gpoDisplayName parameter is null.

ObjectDisposedException

The GroupPolicyObject is disposed.

Remarks

The new GPO is opened according to the value of the readOnly and loadRegistry parameters.

To open an existing GPO, you can use one of the overloaded OpenDSGpo methods.

See Also

CreateNew Overload
GroupPolicyObject Class
Microsoft.GroupPolicy Namespace

Return to top