Hi All,
So I currently have this code:
Import-Module ActiveDirectory
$searchOU = 'CN=District,CN=Test2,DC=csd,DC=local'
Get-ADuser -filter * -searchbase $searchOU -properties DistinguishedName | Select -expandProperty DistinguishedName
And I keep on getting a error where it says:
Get-ADuser : Directory object not found
At C:\Users\singhj\Documents\GitHub\PowerShell\cleanup\test.ps1:3 char:1
+ Get-ADuser -filter * -searchbase $searchOU -properties DistinguishedName |
Selec ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (:) [Get-ADUser], ADIdentityNotF
oundException
+ FullyQualifiedErrorId : Directory object not found,Microsoft.ActiveDirec
tory.Management.Commands.GetADUser
My thoughts were is it I'm possibly running my script wrong? I'm doing right on PowerShell right from my machine and I do have domain admin rights and know I can make changes to AD using remote tools. The place I want to test on is ***.*****(server) -> Distrct -> Test2. I have tried in the second line changing the type to CN = incase maybe using OU was incorrect but that didn't seem to help. Any thoughts or help on this would be great. Thanks. And if I didn't explain enough or if more info is needed let me know.