Hi all,
Wrote script to parse sub OU's of a specific parent OU. Then for each of the sub OU's parsed, enumerate any computers within those OU's. When I run my script, it generates two errors but then proceeds to run the script/output successfully. Just wondering if anyone knows why the error kicks out? Curious why PS doesn't like it.
$objOUS=Get-ADOrganizationalUnit -filter * -Searchbase "ou=Workstations,ou=West,dc=contoso,dc=com" | sort | foreach {$_.Name}
ForEach ($objOU in $objOUS)
{
Get-ADObject -filter * -searchbase "ou=$objOU,ou=Workstations,ou=West,dc=contoso,dc=com" | sort | foreach {$_.Name}
}
The following error is generated twice then proceeds to process the script successfully:
Get-ADObject : Directory object not found
At C:\temp\oumem.ps1:4 char:1
+ Get-ADObject -filter * -searchbase
"ou=$objOU,ou=Workstations,ou=West ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~
+ CategoryInfo : ObjectNotFound: (:) [Get-ADObject], ADIdentityNo
tFoundException
+ FullyQualifiedErrorId : Directory object not found,Microsoft.ActiveDirec
tory.Management.Commands.GetADObject
Thanks