I´m struggling with getting a list of computers from a specific OU via the Get-ADComputer cmdlet. The OU contains only computers. I specify the OU where the computers are placed and then I try to filter the objects based on hostname.
I want to list all computers whose hostname begins with "PC100". No matter what comes after the second zero.
The code:
Get-ADComputer -SearchBase "OU=PC,OU=LAB,DC=test,DC=cz" -Filter * | Select-Object name | where -Property Name -Match "PC100*"
I went through plenty of articles but haven't figured it out yet. PowerShell doesn't return any error, it simply doesn't generate any output.