How to add one more OU on $DomainName

Welcome Forums General PowerShell Q&A How to add one more OU on $DomainName

This topic contains 2 replies, has 3 voices, and was last updated by

 
Keymaster
7 months ago.

  • Author
    Posts
  • #100978

    Participant
    Points: 0
    Rank: Member

    Hello world!!!
    How to add one more OU on $DomainName? I would like to add 'LDAP://OU=TST,DC=fenix,DC=com' and keep 'LDAP://CN=Computers,DC=fenix,DC=com'.

    $DomainName = 'LDAP://CN=Computers,DC=fenix,DC=com'
    $Root = New-Object DirectoryServices.DirectoryEntry $DomainName
    $objSearcher = New-Object DirectoryServices.DirectorySearcher
    $objSearcher.SearchRoot = $Root
    $objSearcher.SearchScope = "SubTree"

    $ADResults = @()

    $colResults = $objSearcher.FindAll()
    foreach ($objResult in $colResults)

  • #100989

    Participant
    Points: 269
    Helping Hand
    Rank: Contributor

    I'm not sure if I got you right but you can create a new organizational unit simply with the cmdlet of the module ActiveDirectory
    New-ADOrganizationalUnit.

  • #101011

    Keymaster
    Points: 1,704
    Helping HandTeam Member
    Rank: Community Hero

    A computer can't live in more than one OU.

The topic ‘How to add one more OU on $DomainName’ is closed to new replies.