arrays - Unable to query [adsisearcher] for trusted domains (PowerShell) -
i wanted query [adsisearcher] me ou info few servers servers in trusted & non trusted domains.
$session = new-pssession -computername icvmm02 invoke-command -session $session -scriptblock { $compname= (get-wmiobject "win32_computersystem" -namespace "root\cimv2" -computername $comp).name $searcher = [adsisearcher]"(&(objectcategory=computer)(name=$compname))" $ou= $searcher.findone() | select-object path $serverou = $ou.path } $adou= (invoke-command -session $session -scriptblock { $serverou }) get-pssession | remove-pssession
for servers in trusted domains im passing $cred = credentials while creating pssession, when run
$compname= (get-wmiobject "win32_computersystem" -namespace "root\cimv2" -computername $comp).name $searcher = [adsisearcher]"(&(objectcategory=computer)(name=$compname))" $ou= $searcher.findone() | select-object path
it gives me error
exception calling "findone" "0" argument(s): "an operations error occurred. " @ line:1 char:27 + $ou= $searcher.findone <<<< () | select-object path + categoryinfo : notspecified: (:) [], methodinvocationexception + fullyqualifiederrorid : dotnetmethodexception $serverou = $ou.path
could 1 please me in sorting out.
i don't cause adsi interface doesn't work in remote sessions. can't dn of domain of computer in domain. can run locally not remotely:
icm { ([adsi]"").distinguishedname } #works icm -session $s -scriptblock { ([adsi]"").distinguishedname } #doesn't work
Comments
Post a Comment