Pass parameter t odistingushed name

i want to make script for getdistingushed name from active directory but everytime i receive error
my script is

param (

# ime organizacione jedinice

$DN= ‘“OU=”’ + $ou + ‘,DC=domain,DC=local"’;
Get-ADComputer -Filter * -SearchBase $DN | Get-AdmPwdPassword -ComputerName {$_.Name};

Are we allowed to know which error you get? :smirk: Please share the complete error message posted as text formatted as code.

And please make sure all the code you post is formatted as code.

Thanks in advance.

 .\get-lp.ps1 -ou "SAVET"
Get-ADComputer : The supplied distinguishedName must belong to one of the following partition(s): 'DC=domain,DC=local ,
CN=Configuration,DC=domain,DC=local , CN=Schema,CN=Configuration,DC=domain,DC=local , DC=DomainDnsZones,DC=domain,DC=local ,
At C:\users\gljubic.domain\scripts\get-lp.ps1:7 char:1
+ Get-ADComputer -Filter * -SearchBase $DN | Get-AdmPwdPassword -Comput ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-ADComputer], ArgumentException
    + FullyQualifiedErrorId : ActiveDirectoryCmdlet:System.ArgumentException,Microsoft.ActiveDirectory.Management.Comm

I urgently recommend to learn how to debug your own code. :wink:

When you pass "SAVET" with the parameter -OU your code does this:

$DN = '"OU="' + $ou + ',DC=domain,DC=local"'

Now please output


Does it look ok? :wink:

1 Like