Author Posts

January 15, 2016 at 7:15 am

Hi,
I am querying a user for an AD group name. I then want to confirm the group is in AD. However, the group name has spaces. I have tried many things to deal with this, none of which is successful. This is an excerpt of the script I am using:

$Trustee = 'WinNT://',"$env:userdomain",'/',"$trustee" -join "
$ADResolve = ([adsisearcher]"(samaccountname=$Trustee)").findone().properties['samaccountname']

Can someone help me?
Thanks!

January 15, 2016 at 7:17 am

With that syntax, you're usually querying for the samAccountName, which doesn't usually have spaces... that's different from the display name.

But, out of curiosity, why wouldn't you use either Get-ADGroup, or the LDAP:// provider, versus WinNT://? Going through the old-old-old WinNT interface seems like you'd always just run across challenges.