Dealing with Spaces from a Query

This topic contains 2 replies, has 2 voices, and was last updated by  bvi1998 . 2 years, 5 months ago.

  • Author
  • #33939

    bvi1998 .

    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?

  • #33940

    Don Jones

    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.

You must be logged in to reply to this topic.