B.4 Category Operations

The following sections provide the scriptable operations that can be carried out on the category object.

B.4.1 Create GPO

Create a GPO under a category.

Syntax

New-GPRGpo [-FAGPRPath] <String> [-Name] <String>

Parameter

Value

FAGPRPath

The FAGPRPath of the new GPO.

Name

The name of the new GPO.

Sample Code

NOTE:Before executing this cmdlet, run Set-GPRConnection to establish a connection to the GPA Repository database. See the PowerShell cmdlet sample for more information.

The following sample creates a repository GPO in GPDOM.LAB.

PS C:\>New-GPRGpo -FAGPRPath "FAGPR://CN=Meger Scripts, DC=GPDOM,DC=LAB" -Name "SoftwarePolicy"

B.4.2 Delete Category

Deletes a category. This operation would delete all GPOs and subcategories. To use this command, all GPOs in the category must be checked in.

Syntax

Remove-GPRCategory [-FAGPRPath] <String>

Parameter

Value

FAGPRPath

The FAGPRPath of the category.

Sample Code

NOTE:Before executing this cmdlet, run Set-GPRConnection to establish a connection to the GPA Repository database. See the PowerShell cmdlet sample for more information.

The following sample deletes the category 'Test' from the GPDOM.LAB domain.

PS C:\>Remove-GPRCategory -FAGPRPath "FAGPR://CN=Test, DC=GPDOM,DC=LAB"

B.4.3 Import GPO from Active Directory

Import an existing Active Directory GPO into a category.

Understanding LDAP Path and Overwrite Flag

This operation includes parameters that are defined as follows:

GPOLDAPPath

Specifies the LDAP path of the GPO that needs to be imported from a live Active Directory domain. To obtain the LDAP path of the GPO (LDAP://...), use the ADSI Edit tool. If the ADSI Edit tool is not available, substitute the following information in the LDAP path:

"LDAP://DomainController/CN={GUID},CN=Policies,CN=System,DC=Domain"

The parameters in this syntax statement are defined as follows:

DomainController

Type the name of the primary domain controller of the domain. Provide the full computer name, which has the actual computer name along with the domain to which it belongs. You can find the full name on the Network Identification tab of the Property page of My Computer.

GUID

Type the GUID number that corresponds to the GPO you want to import.

Domain

Type the name of the domain to which the GPO belongs. The domain name should be in the distinguished name format. For example, to specify the domain name, mydomain.com, the syntax should be DC=MYDOMAIN, DC=COM.

ADSIGPOObject

Specifies and ADSI pointer to the GPO in Active Directory.

OverwriteFlag

Specifies the overriding condition for the import. The values are False and True. False denotes do not override if the GPO already exists in the domain. True denotes override the existing GPO.

Syntax

Import-GPRADGpo [-FAGPRPath] <String> [-GpoLdapPath] <String> [-Overwrite] <SwitchParameter>

Parameter

Value

FAGPRPath

The FAGPRPath of the new GPO.

GpoLdapPath

The LDAP path of the GPO that you want to import from a live Active Directory domain.

To obtain the LDAP path of the GPO, use the ADSI Edit tool. If it is not available, substitute the following information for the LDAP path: LDAP://DomainController/CN={GUID},CN=Policies,CN=System,DC=Domain.

Overwrite

Specifies whether or not to overwrite the GPO if it already exists in the GP Repository. You don't have to specify a value with this parameter.

Sample Code

NOTE:Before executing this cmdlet, run Set-GPRConnection to establish a connection to the GPA Repository database. See the PowerShell cmdlet sample for more information.

The following sample imports an Active Directory GPO from GPDOM.LAB to the GP Repository.

PS C:\>Import-GPRADGpo  -FAGPRPath "FAGPR://CN=MyCategory, DC=GPDOM,DC=LAB" -GPOLDAPPath "LDAP://[DomainControler]/CN={000344FD-1494-45A4-BF39-5022C4B4741A},CN=Policies,CN=System,DC=GPDOM,DC=LAB" -Overwrite