###Code Example###
function verify_domain
{
$erroractionpreference = "SilentlyContine"
$exist = [ADSI]::Exists("LDAP://" + $dn)
if ($exist -ne 'True')
{
do something
}
}
### CODE BLOCK END###
Works no problem when querying an OU DN path (i.e.
OU=paul,DC=domain,DC=lcl). However, if I just pass a Domain DN (i.e.
DC=domain,DC=lcl), the i get what i think is a referral error however but
shouldn't the $erroractionpreference = "silentlycontinue" prevent that. The
actual error I get is:
Exception calling "Exists" with "1" argument(s): "A referral was returned
from the server"
My DC DNS is configured to forward "All other domains" to another DNS server
so I can kinda understand the response. So...how do I account for this
response and give a more "friendly" message and script exit. If necessary to
help, I can provide the entire code. Thanks in advance.
###WORKING CODE EXAMPLE###
function verify_domain
{
$erroractionpreference = "SilentlyContine"
> TRAP
> {
> CONTINUE
> }
$exist = [ADSI]::Exists("LDAP://" + $dn)
if ($exist -ne 'True')
{
do something
}
}
### WORKING CODE BLOCK END###
btw While it doesn't make a difference in your code snippet. You should be
setting back to continue before exiting. If this were ever dot-sourced you'd
be eliminating any warnings
$erroractionpreference="Continue"
- Larry