New-AppLockerPolicy

New-AppLockerPolicy

Creates a new AppLocker policy from a list of file information and other rule-creation options.

Syntax

New-AppLockerPolicy [-FileInformation] <FileInformation[]> [-RuleType <RuleType[]>] [-RuleNamePrefix <String>] [-User <String>] [-Optimize <Boolean>] [-IgnoreMissingFileInformation <Boolean>] [-XML <Boolean>] [<CommonParameters>]

Detailed Description

The New-AppLockerPolicy cmdlet uses a list of file information to automatically generate rules for a given user or group. It can generate rules based on publisher, hash, or path information. Use Get-AppLockerFileInformation to create the list of file information.

Parameters

-FileInformation <FileInformation[]>

A file can contain publisher, path, and hash information. Some information may be missing, such as publisher information for an unsigned file.

Attributes

Name Value

Required?

true

Accept wildcard characters?

false

Accept Pipeline Input?

true (ByValue)

Position?

0

-RuleType <String[]>

Specifies the type of rules to create from the file information. Publisher, path, or hash rules can be created from the file information. Multiple rule types may be specified so that there are backup rule types if the necessary file information is not available. For example, you can specify -RuleType Publisher, Hash so that hash rules are applied when publisher information is not available. Publisher, Hash is the default value.

Attributes

Name Value

Required?

false

Accept wildcard characters?

false

Accept Pipeline Input?

false

Position?

named

-RuleNamePrefix <String>

Specifies a name to add as a prefix to each rule that is created.

Attributes

Name Value

Required?

false

Accept wildcard characters?

false

Accept Pipeline Input?

false

Position?

named

-User <String>

Defines the user or group that the rules are applied to. You must provide the value in one of the following formats:
DNS user name (domain\username)
User Principal Name (username@domain.com)
SAM user name (username)
Security identifier (S-1-5-21-3165297888-301567370-576410423-1103)

Attributes

Name Value

Required?

false

Accept wildcard characters?

false

Accept Pipeline Input?

false

Position?

named

-Optimize <Boolean>

Instructs similar rules to be grouped together.

Attributes

Name Value

Required?

false

Accept wildcard characters?

false

Accept Pipeline Input?

false

Position?

named

-IgnoreMissingFileInformation <Boolean>

Instructs the cmdlet to continue to execute if a rule cannot be created for a file because file information is missing. A warning log of the files skipped is generated.

Attributes

Name Value

Required?

false

Accept wildcard characters?

false

Accept Pipeline Input?

false

Position?

named

-XML <Boolean>

Specifies the output of the new AppLocker policy as an XML-formatted string.

Attributes

Name Value

Required?

false

Accept wildcard characters?

false

Accept Pipeline Input?

false

Position?

named

-CommonParameter

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see About Common Parameter

Input and Return Types

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

Input Type

.

Return Type

By default, New-AppLockerPolicy returns an AppLockerPolicy object. If you use the XML parameter, it will return the AppLocker policy as an XML string..

Notes

Examples

EXAMPLE 1

C:\PS>Get-ChildItem C:\Windows\System32\*.exe | Get-AppLockerFileInformation | New-AppLockerPolicy -RuleType Publisher, Hash -User Everyone -RuleNamePrefix System32

Creates an AppLocker policy containing allow rules for all of the executable files in C:\Windows\System32. The policy contains publisher rules for those files with publisher information and hash rules for those that do not. The rules are prefixed with "System32:" and the rules apply to the Everyone group.

EXAMPLE 2

C:\PS>Get-ChildItem C:\Windows\System32\*.exe | Get-AppLockerFileInformation | New-AppLockerPolicy -RuleType Path -User Everyone -Optimize -XML

Creates an XML-formatted AppLocker policy for all of the executable files in C:\Windows\System32. The policy contains only path rules, the rules are applied to the Everyone group, and the Optimize parameter indicates that similar rules are grouped together where possible.

EXAMPLE 3

C:\PS>Get-AppLockerFileInformation -EventLog -LogPath "Microsoft-Windows-AppLocker/EXE and DLL" -EventType Audited | New-AppLockerPolicy -RuleType Publisher,Hash -User domain\FinanceGroup -IgnoreMissingFileInformation | Set-AppLockerPolicy -LDAP "LDAP://DC13.TailspinToys.com/CN={31B2F340-016D-11D2-945F-00C04FB984F9},CN=Policies,CN=System,DC=WingTipToys,DC=com"

Creates a new AppLocker policy from the audited events in the local Microsoft-Windows-AppLocker/EXE and DLL event log. All of the rules will be applied to the domain\FinanceGroup group. Publisher rules are created when the publisher information is available, and hash rules are created if the publisher information is not available. If only path information is available for a file, the file is skipped because the IgnoreMissingFileInformation parameter is specified, and the file is included in the warning log. If the IgnoreMissingFileInformation parameter is not specified, when file information is missing, the cmdlet exits because it cannot create the specified rule type. After the new AppLocker policy is created, the AppLocker policy of the specified Group Policy Object (GPO) is set. The existing AppLocker policy in the specified GPO will be overwritten.

See Also

Reference

Get-AppLockerPolicy
Set-AppLockerPolicy
Test-AppLockerPolicy
Get-AppLockerFileInformation