EvotecIT / ADEssentials

PowerShell Active Directory helper functions to manage healthy Active Directory
MIT License
429 stars 51 forks source link

Cannot Get-WinADGroupMemberOf of Identity with '@' symbol #16

Closed JerHowden closed 3 years ago

JerHowden commented 3 years ago

This line in Get-WinADGroupMemberOf passes the Identity parameter to Get-WinADObject

https://github.com/EvotecIT/ADEssentials/blob/d316cc9a26ee79f10ddf82796d09b10555fc6677/Public/Get-WinADGroupMemberOf.ps1#L25

And with an @ symbol this breaks here in Get-WinADObject

https://github.com/EvotecIT/ADEssentials/blob/d316cc9a26ee79f10ddf82796d09b10555fc6677/Public/Get-WinADObject.ps1#L164

Capture

JerHowden commented 3 years ago

image The same also happens with Get-WinADGroupMember

PrzemyslawKlys commented 3 years ago

I always assumed that using @ in the name means you are dealing with UPN. I was not aware people will use @ in the Name causing DN having @ sign. I was not aware it's possible to use @ in UPN as well but it seems T@ta@domain.pl is valid UPN, which complicates a lot of my scripts logic.

JerHowden commented 3 years ago

It is unfortunate that this naming scheme is accepted. For the Member and MemberOf scripts, would it be possible to pass along the domain name parameter in order to skip this check altogether?

PrzemyslawKlys commented 3 years ago

I'll just have to fix - instead of doing like @ i will first check if it's DistiniguishedName and then if not go further. I have some ideas. Just need some time.