You’re not passing anything to the Get-ADUser command from the pipeline, so it will return on the Get-ADUser filter since you’re not passing anything to Get-ADUser.
If there was a sub-OU on your filtered OU, you’d receive an error:
Get-ADUser : The input object cannot be bound to any parameters for the command either because the command does not
take pipeline input or the input and its properties do not match any of the parameters that take pipeline input.
Your “Get-ADUser” works independend of the cmdlet before the pipe. You specified everything it needs to work properly. What do you want to achive with this code? If you like to limit the OUs the cmdlet searches in you will have to use a loop and reference the pipeline object … something like this:
… !!! but because you’re specifying the -SearchBase as the OU you like to limit to you will not get any result. You should change the -SearchBase to something “higher” in the tree.
Please try to avoid backticks. They are ugly, hard to see (a lot of us are not 22 anymore ), error prone and most of the time unnecessary. Especially when you have a pipe symbol direct in front of it. Line breaks are allowed after commata, semicola, opening parenthesis or curly braces AND pipe symbols!!
I think you can even shorten this a bit more. Try this: