Set-AppLockerPolicy

Set-AppLockerPolicy

Sets the AppLocker policy for the specified Group Policy Object (GPO).

Syntax

Parameter Set: ByXmlPolicy
Set-AppLockerPolicy [-XmlPolicy] <String> [-Ldap <String> ] [-Merge] [-Confirm] [-WhatIf] [ <CommonParameters>]

Parameter Set: ByPolicyObject
Set-AppLockerPolicy [-PolicyObject] <AppLockerPolicy> [-Ldap <String> ] [-Merge] [-Confirm] [-WhatIf] [ <CommonParameters>]

Detailed Description

The Set-AppLockerPolicy cmdlet sets the specified GPO to contain the specified AppLocker policy. If no Lightweight Directory Access Protocol (LDAP) is specified, then the default is the local GPO.

The input values for the AppLocker policy can be an AppLockerPolicy object or an XML-formatted file containing the AppLocker policy.

Parameters

-Ldap<String>

Specifies the LDAP path of the GPO. It must specify a unique GPO. If this parameter is not specified, then the local AppLocker policy is set.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Merge

Merges the rules in the specified AppLocker policy with the AppLocker rules in the target GPO specified in the LDAP path. The merging of policies will remove rules with duplicate rule IDs, and the enforcement setting specified by the AppLocker policy in the target GPO will be preserved. If the Merge parameter is not specified, then the new policy will overwrite the existing policy.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-PolicyObject<AppLockerPolicy>

Specifies the AppLockerPolicy object that contains the AppLocker policy. Can be obtained from the Get-AppLockerPolicy and the New-AppLockerPolicy cmdlets.

Aliases

none

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

true (ByValue, ByPropertyName)

Accept Wildcard Characters?

false

-XmlPolicy<String>

Specifies the path where the XML-formatted file containing the AppLocker policy is saved.

Aliases

none

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Confirm

Prompts you for confirmation before running the cmdlet.

Required?

false

Position?

named

Default Value

false

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Required?

false

Position?

named

Default Value

false

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see    about_CommonParameters (https://go.microsoft.com/fwlink/p/?LinkID=113216).

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • Microsoft.Security.ApplicationId.PolicyManagement.PolicyModel.AppLockerPolicy

    AppLockerPolicy

  • System.String

Outputs

The output type is the type of the objects that the cmdlet emits.

  • None

Examples

EXAMPLE 1

This example sets the local AppLocker policy to the policy specified in C:\Policy.xml.

PS C:\> Set-AppLockerPolicy -XMLPolicy C:\Policy.xml

EXAMPLE 2

This example sets the GPO specified in the LDAP path to contain the AppLocker policy that is specified in C:\Policy.xml.

PS C:\> Set-AppLockerPolicy -XMLPolicy C:\Policy.xml -LDAP "LDAP://DC13.Contoso.com/CN={31B2F340-016D-11D2-945F-00C04FB984F9},CN=Policies,CN=System,DC=Contoso,DC=com"

EXAMPLE 3

This example gets the local AppLocker policy, and then merges the policy with the existing AppLocker policy in the GPO specified in the LDAP path. See the Merge parameter description for more details on how two policies are merged.

PS C:\> Get-AppLockerPolicy -Local | Set-AppLockerPolicy -LDAP "LDAP://DC13.Contoso.com/CN={31B2F340-016D-11D2-945F-00C04FB984F9},CN=Policies,CN=System,DC=Contoso,DC=com" -Merge

Get-AppLockerFileInformation

Get-AppLockerPolicy

New-AppLockerPolicy

Test-AppLockerPolicy