Author Posts

October 15, 2015 at 5:25 am

PS C:\> $error[0]

Set-Acl : Attempted to perform an unauthorized operation.
At line:1 char:8
+ set-acl < <<<  c:\test -AclObject $acl
    + CategoryInfo          : PermissionDenied: (C:\test:String) [Set-Acl], UnauthorizedAccessException
    + FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.SetAclCommand

Is there a way to have $errror[0] just show 'Attempted to perform an unauthorized operation.' in this example?

October 15, 2015 at 5:33 am



October 15, 2015 at 5:35 am

I typically use:


October 15, 2015 at 5:36 am

Well, you could do $error[0].Exception.Message . If you just want to change the formatting of the ErrorRecord objects, that's a bit more involved. However, there is one easy solution that you might like: $ErrorView = 'CategoryView'

October 15, 2015 at 5:47 am

Damn you guys rock, thats perfect! Thanks all!