last day (14 days later) » 

1:22 PM
Hello, Mathias. i'm sorry to join this chat with days of delay
 
1:37 PM
Hey man
No worries
What I wanted you to do was simply to use Write-Host instead of New-ADOrganizationalUnitin the last foreach loop, and them tell me what output you got
You should expect the following output on the screen:

"OU=Users,DC=local,DC=contoso"
"OU=IT Dept,OU=Users,DC=local,DC=contoso"
"OU=HelpDesk,OU=IT Dept,OU=Users,DC=local,DC=contoso"
except for the "s
 
hey :)
I expected that too, but I got an error that I really didn't understand
let me get that error again, a minute please
Exception calling "Exists" with "1" argument(s): "A referral was returned from the server.
"
At C:\Users\Administrator\Desktop\create-ou.ps1:13 char:8
+ if(($NextOU.IndexOf("OU=") -ne 0) -or ([ADSI]::Exists("LDAP://$NextOU")))
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DirectoryServicesCOMException
I tried to find the error in that line
But I really didn't find. I'm new to powershell, so I lack some experience to find the errors :)
That line even is the your original line, though
Let me try again, exactly with your code
 
Ahh, you're not logged in as a domain user are you?
C:\Users\Administrator <-- is that the local Administrator on the machine or a Domain Admin ?
 
actually I am.
Domain admin
 
Ahh, didn't see the error
 
let me double check
 
1:49 PM
Are these OU paths from the same domain as your own user domain?
 
I'm logged with the domain admin
 
Yes, but is "DC=local,DC=contoso" the DN of your domain or another domain?
 
shure, my domain isn't contoso :)
 
If it's the path to an object in another domain than the one whose Domain Controllers you are querying, you would get that referral error
 
hm, make sense
let me try with my domain
 
1:52 PM
So [ADSI]::Exists() method will only work if you supply LDAP paths for objects in that domain
I've made a more verbose/debug-friendly version here: pastebin.com/mdcDDZ2U
Wait, like this: pastebin.com/6pkj1i2y
save it to a *.ps1 file and supply the -Verbose parameter when you run it
.\Create-OU.ps1 -DN "OU=HelpDesk,OU=IT Dept,OU=Users,DC=local,DC=contoso" -Verbose
 
OK, let's try that
Same error. Weird. I think i'm doing something stupid when I put the path with my real domain
let me check
 
remember that my.domain.com becomes DC=my,DC=domain,DC=com
 
That part i'm doing right
Man, even with a existing path, it still giving me the same error
Exception calling "Exists" with "1" argument(s): "Unknown error (0x80005000)"
At C:\Users\Administrator\Desktop\verbosecreate.ps1:26 char:12
+ elseif([ADSI]::Exists("LDAP://$NextOU/"))
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : COMException
It's weird, cause if I just use the "[adsi]::Exists("LDAP://$Path/") ou of the script, it works
 
Would you mind disclosing the real DN you're using. DM me on twitter if you don't want it here on stackexchange
 
And man, if I'm taking too much of your time, please do not hesitate to tell me, ok?
Will, DM, a sec
 
2:06 PM
I'm out of work for the next week or so, I don't mind ;)
 
Can't DM, you not following me :)
 
try again
 
just sent the path
well, should [ADSI]::Exists("LDAP://local.iq.ufrj.br/") work?
 
Yes, that should return true since the root of the domain exists :)
 
error :(
same error
wtf man
 
2:14 PM
Try:

([adsi]"LDAP://RootDSE").dnsHostName
It should return the domain FQDN
 
oh
pewter.local.iq.ufrj.br
 
There you go ;)
 
that doesn't seems to be right
 
Is the computer on which you are running these scripts a member of the pewter child domain ? :)
 
pewter is the machine name
 
2:16 PM
Just change [ADSI]::Exists("LDAP://$NextOU/") to [ADSI]::Exists("LDAP://local.iq.ufrj.br/$NextOU/")
And run the newest version of the script again
I have to run for something before the shop closes, I'll be back in an hour or two :)
 
No problem
thank you very much for your help
 

last day (14 days later) »