Dealing with Spaces from a Query

Tagged: 

This topic contains 2 replies, has 2 voices, and was last updated by  bvi1998 . 10 months, 3 weeks ago.

  • Author
    Posts
  • #33939
    Profile photo of bvi1998 .
    bvi1998 .
    Participant

    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!

  • #33940
    Profile photo of Don Jones
    Don Jones
    Keymaster

    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.