Hello,
I would expect
get-adgroup S-1-5-21-842925246-2139871995-725345543-351830 -erroraction silentlycontinue -errorvariable err
To fail silently when SID does not match any existing group
It actually still exposes the stack:
get-adgroup S-1-5-21-842925246-2139871995-725345543-351830 -erroraction silentlycontinue -errorvariable err
get-adgroup : Cannot find an object with identity: 'S-1-5-21-842925246-2139871995-725345543-351830' under:
'DC=xxx,DC=redacted,DC=com'.
At line:1 char:1
+ get-adgroup S-1-5-21-842925246-2139871995-725345543-351830 -erroracti ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (S-1-5-21-842925...25345543-351830:ADGroup) [Get-ADGroup], ADIdentityNot
FoundException
+ FullyQualifiedErrorId : ActiveDirectoryCmdlet:Microsoft.ActiveDirectory.Management.ADIdentityNotFoundException,M
icrosoft.ActiveDirectory.Management.Commands.GetADGroup
Do I need to understand that Get-ADGroup does not respect Common parameters and I absolutely need a try/catch block to hide those ?