I have a piece of code like:
...
32: try {
33: set-acl -aclObject $AC -path $o.fullname
34: } catch [System.UnauthorizedAccessException] {
...
During execution I get this:
set-acl : Attempted to perform an unauthorized operation.
At C:\script.ps1:33 char:3
+ set-acl -aclObject $AC -path $o.fullname
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : PermissionDenied: (N:\some_path:String) [Set-Acl], UnauthorizedAccessException
+ FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.SetAclCommand
Running as system. Any idea why it's not being captured?
Try setting the
ErrorActionparameter toStop: