I have the following script for creating an OU. This works as expected.
If however I try to dynamically grab the domain info it fails
Can anyone assist?
Code:
$objDomain = [ADSI]"LDAP://localhost:389/DC=MyCompany,DC=Local"
$objOU = $objDomain.Create("organizationalUnit", "ou=MarkTestOU")
$objOU.SetInfo()
If however I try to dynamically grab the domain info it fails
Code:
$RootDSE = New-Object directoryservices.directoryentry('LDAP://rootDSE')
$Root = New-Object directoryservices.directoryentry("LDAP://$($RootDSE.DefaultNamingContext)")
$objDomain = [ADSI]"LDAP://localhost:389/"+$Root.DistinguishedName
$objOU = $objDomain.Create("organizationalUnit", "ou=MarkTestOU")
$objOU.SetInfo()
Can anyone assist?