i want to make script for getdistingushed name from active directory but everytime i receive error
my script is
param (
# ime organizacione jedinice
[string]$ou
)
$DN= ‘“OU=”’ + $ou + ‘,DC=domain,DC=local"’;
Get-ADComputer -Filter * -SearchBase $DN | Get-AdmPwdPassword -ComputerName {$_.Name};
Olaf
2
Are we allowed to know which error you get? 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 ,
DC=ForestDnsZones,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
ands.GetADComputer
Olaf
4
I urgently recommend to learn how to debug your own code.
When you pass "SAVET"
with the parameter -OU
your code does this:
$OU = 'SAVET'
$DN = '"OU="' + $ou + ',DC=domain,DC=local"'
Now please output
$DN
Does it look ok?
1 Like