Using variable in distinguishedName

Welcome Forums General PowerShell Q&A Using variable in distinguishedName

This topic contains 1 reply, has 2 voices, and was last updated by

 
Participant
3 months, 2 weeks ago.

  • Author
    Posts
  • #110476

    Participant
    Points: 1
    Rank: Member

    Hi all,

    I get following error when using a variable, when using the name (TestComAccount2)  it works

    code:

    get-adgroup -server enc-cap-eds-03.ee.intern "CN=xx-GG-CitrixCloud-Computers-VDI,OU=Citrix,OU=Server Applications,OU=Administration,OU=xxx,DC=xx,DC=xx" | remove-adgroupmember -Members "CN=$Disabeldaccounts,OU=testou,OU=CC-Citrix Cloud Connector,OU=Citrix Services,OU=Infrastructure Services,OU=Servers,OU=xxxx,DC=xx,DC=xxx"

    Error message:

    remove-adgroupmember : Cannot find an object with identity: 'CN=@{Name=TestComAccount2}.name,OU=testou,OU=CC-Citrix Cloud Connector,OU=Citrix Services,OU=Infrastructure

    Services,OU=Servers,OU=xxx,DC=xx,DC=xxx' under: 'DC=xxx,DC=xxx'.

     

    do i need to specify the variable different???

     

    thnx paul

     

  • #110489

    Participant
    Points: 261
    Helping Hand
    Rank: Contributor

    Please use the code posting tags when you post code.
    I assume you need to resolve the subexpression to use it this way.

    get-adgroup -server enc-cap-eds-03.ee.intern "CN=xx-GG-CitrixCloud-Computers-VDI,OU=Citrix,OU=Server Applications,OU=Administration,OU=xxx,DC=xx,DC=xx" | 
        remove-adgroupmember -Members "CN=$($Disabeldaccounts.Name),OU=testou,OU=CC-Citrix Cloud Connector,OU=Citrix Services,OU=Infrastructure Services,OU=Servers,OU=xxxx,DC=xx,DC=xxx"

The topic ‘Using variable in distinguishedName’ is closed to new replies.