ad-password-protection icon indicating copy to clipboard operation
ad-password-protection copied to clipboard

AggregateExceptions are hiding the real error in PowerShell output

Open AaronGenter opened this issue 5 years ago • 4 comments

When I try to use Powershell to add a custom BannedWord or CompromisedPassword, I get the following error:

PS C:\Windows\system32> Add-BannedWord -Value "glass" Add-BannedWord : One or more errors occurred. At line:1 char:1

  • Add-BannedWord -Value "glass"
  •   + CategoryInfo          : NotSpecified: (:) [Add-BannedWord], AggregateException
      + FullyQualifiedErrorId : System.AggregateException,Lithnet.ActiveDirectory.PasswordProtection.PowerShell.AddBannedWord
    
    

PS C:\Windows\system32> Add-CompromisedPassword -Value "glass" Add-CompromisedPassword : One or more errors occurred. At line:1 char:1

  • Add-CompromisedPassword -Value "glass"
  •   + CategoryInfo          : NotSpecified: (:) [Add-CompromisedPassword], AggregateException
      + FullyQualifiedErrorId : System.AggregateException,Lithnet.ActiveDirectory.PasswordProtection.PowerShell.AddCompromisedPassword
    
    

Thank you!

AaronGenter avatar Jul 31 '19 16:07 AaronGenter

It appears the command doesn't use the default store, as mentioned in the Open-Store Wiki, and you have to run Open-Store first.

AaronGenter avatar Jul 31 '19 16:07 AaronGenter

Hi Aaron,

Can you send me the result of running the following command immediately after getting that error.

$error[0].Exception.ToString()

ryannewington avatar Jul 31 '19 19:07 ryannewington

Looks like it's my bad... When I do open-store I went right to the file system location and didn't use the share. The share was setup as read-only. Thank you for the command to show the error message: System.AggregateException: One or more errors occurred. ---> System.UnauthorizedAccessException: Access to the path '\servername\lpp$\v3\w\AE2C.db.bin' is denied.

Sorry for the bogus issue! After fixing the share permissions, it is working as expected.

AaronGenter avatar Jul 31 '19 20:07 AaronGenter

That's ok. I'll need to fix the error reporting to make it more clear what was going on.

ryannewington avatar Jul 31 '19 20:07 ryannewington