group policy - How to Create Deny rules for Applocker using Powershell -


when using command such

ls 'c:\program files\*.exe' | get-applockerfileinformation | new-applockerpolicy -ruletype path -user -xml -optimize 

i see emit "allow" rule. how can generate "deny" rule (i.e action="deny") in xml gets generated. msdn documentation not having deny option. xml fiddling way?

you modify policy rule objects new-applockerpolicy returns before calling set-applockerpolicy:

$policy = ls 'c:\program files\*.exe' | get-applockerfileinformation | new-applockerpolicy -ruletype path -user -optimize foreach($rulecollection in $policy.rulecollections) {     foreach($rule in $rulecollection)     {         $rule.action = 'deny'     } } set-applockerpolicy -policyobject $policy -ldap "<dn target policy>" 

in powershell 4.0 , newer, can use foreach({}) extension method well:

$policy = ... | new-applockerpolicy $policy.rulecollections.foreach({ $_.foreach({ $_.action = 'deny' }) }) set-applockerpolicy -policyobject $policy -ldap ... 

Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -