GroupPolicyObject.CreateNew Method (Domain, String, Boolean, Boolean)
Creates a new Group Policy object (GPO) with the specified display name in the specified domain.
Namespace: Microsoft.GroupPolicy
Assembly: Microsoft.GroupPolicy.Management.Interop (in Microsoft.GroupPolicy.Management.Interop.dll)
Syntax
public void CreateNew(
Domain domain,
string gpoDisplayName,
bool readOnly,
bool loadRegistry
)
public:
void CreateNew(
Domain^ domain,
String^ gpoDisplayName,
bool readOnly,
bool loadRegistry
)
member CreateNew :
domain:Domain *
gpoDisplayName:string *
readOnly:bool *
loadRegistry:bool -> unit
Public Sub CreateNew (
domain As Domain,
gpoDisplayName As String,
readOnly As Boolean,
loadRegistry As Boolean
)
Parameters
domain
Type: System.DirectoryServices.ActiveDirectory.DomainRepresents the domain in which to create the new GPO.
gpoDisplayName
Type: System.StringThe display name for the new GPO.
readOnly
Type: System.Booleantrue to open the GPO in read-only mode; otherwise, false.
loadRegistry
Type: System.Booleantrue to load the registry; otherwise, false.
Exceptions
Exception | Condition |
---|---|
ArgumentException | gpoDisplayName is an empty string (“”). |
ArgumentNullException | The domain 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